@gjermundgaraba/pixel-paper 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +50 -2
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/announcer/announcer.d.ts +35 -0
- package/dist/announcer/announcer.js +121 -0
- package/dist/announcer/index.d.ts +5 -0
- package/dist/announcer/index.js +11 -0
- package/dist/attributes/attributes.d.ts +4 -0
- package/dist/banner/banner.d.ts +20 -0
- package/dist/banner/banner.js +18 -0
- package/dist/banner/index.d.ts +5 -0
- package/dist/banner/index.js +6 -0
- package/dist/bench/bench.d.ts +16 -0
- package/dist/bench/bench.js +12 -0
- package/dist/bench/index.d.ts +5 -0
- package/dist/bench/index.js +6 -0
- package/dist/board/board.d.ts +1151 -0
- package/dist/board/board.js +449 -0
- package/dist/board/index.d.ts +6 -0
- package/dist/board/index.js +21 -0
- package/dist/button/button.d.ts +54 -0
- package/dist/button/button.js +50 -0
- package/dist/button/index.d.ts +5 -0
- package/dist/button/index.js +9 -0
- package/dist/card/card.d.ts +66 -0
- package/dist/card/card.js +70 -0
- package/dist/card/index.d.ts +5 -0
- package/dist/card/index.js +10 -0
- package/dist/chip/chip.d.ts +27 -0
- package/dist/chip/chip.js +34 -0
- package/dist/chip/index.d.ts +5 -0
- package/dist/chip/index.js +9 -0
- package/dist/choice/choice.d.ts +16 -0
- package/dist/choice/choice.js +17 -0
- package/dist/choice/index.d.ts +5 -0
- package/dist/choice/index.js +6 -0
- package/dist/code-editor/code-editor.d.ts +15 -0
- package/dist/code-editor/code-editor.js +22 -0
- package/dist/code-editor/index.d.ts +5 -0
- package/dist/code-editor/index.js +6 -0
- package/dist/code-surface/code-surface.d.ts +12 -0
- package/dist/code-surface/code-surface.js +12 -0
- package/dist/code-surface/index.d.ts +5 -0
- package/dist/code-surface/index.js +6 -0
- package/dist/command-palette/command-palette.d.ts +579 -0
- package/dist/command-palette/command-palette.js +600 -0
- package/dist/command-palette/index.d.ts +9 -0
- package/dist/command-palette/index.js +32 -0
- package/dist/command-palette/keys.d.ts +13 -0
- package/dist/command-palette/keys.js +71 -0
- package/dist/command-palette/match.d.ts +43 -0
- package/dist/command-palette/match.js +45 -0
- package/dist/command-palette/message.d.ts +94 -0
- package/dist/command-palette/message.js +46 -0
- package/dist/confirm-dialog/confirm-dialog.d.ts +287 -0
- package/dist/confirm-dialog/confirm-dialog.js +115 -0
- package/dist/confirm-dialog/index.d.ts +5 -0
- package/dist/confirm-dialog/index.js +17 -0
- package/dist/copy-button/copy-button.d.ts +99 -0
- package/dist/copy-button/copy-button.js +96 -0
- package/dist/copy-button/index.d.ts +5 -0
- package/dist/copy-button/index.js +13 -0
- package/dist/crumbs/crumbs.d.ts +15 -0
- package/dist/crumbs/crumbs.js +11 -0
- package/dist/crumbs/index.d.ts +5 -0
- package/dist/crumbs/index.js +6 -0
- package/dist/deck/deck.d.ts +9 -0
- package/dist/deck/deck.js +9 -0
- package/dist/deck/index.d.ts +5 -0
- package/dist/deck/index.js +6 -0
- package/dist/dialog/dialog.d.ts +278 -0
- package/dist/dialog/dialog.js +145 -0
- package/dist/dialog/fold.d.ts +58 -0
- package/dist/dialog/fold.js +63 -0
- package/dist/dialog/index.d.ts +6 -0
- package/dist/dialog/index.js +21 -0
- package/dist/disclosure/disclosure.d.ts +24 -0
- package/dist/disclosure/disclosure.js +25 -0
- package/dist/disclosure/index.d.ts +5 -0
- package/dist/disclosure/index.js +6 -0
- package/dist/dom/html-element.js +8 -0
- package/dist/drag/drag.d.ts +15 -0
- package/dist/drag/drag.js +123 -0
- package/dist/drop-zone/drop-zone.d.ts +119 -0
- package/dist/drop-zone/drop-zone.js +64 -0
- package/dist/drop-zone/index.d.ts +5 -0
- package/dist/drop-zone/index.js +14 -0
- package/dist/empty-state/empty-state.d.ts +18 -0
- package/dist/empty-state/empty-state.js +16 -0
- package/dist/empty-state/index.d.ts +5 -0
- package/dist/empty-state/index.js +6 -0
- package/dist/error-summary/error-summary.d.ts +34 -0
- package/dist/error-summary/error-summary.js +33 -0
- package/dist/error-summary/index.d.ts +5 -0
- package/dist/error-summary/index.js +6 -0
- package/dist/field/field.d.ts +35 -0
- package/dist/field/field.js +34 -0
- package/dist/field/index.d.ts +5 -0
- package/dist/field/index.js +6 -0
- package/dist/field-grid/field-grid.d.ts +8 -0
- package/dist/field-grid/field-grid.js +8 -0
- package/dist/field-grid/index.d.ts +5 -0
- package/dist/field-grid/index.js +6 -0
- package/dist/fields/fields.js +9 -0
- package/dist/fieldset/fieldset.d.ts +13 -0
- package/dist/fieldset/fieldset.js +13 -0
- package/dist/fieldset/index.d.ts +5 -0
- package/dist/fieldset/index.js +6 -0
- package/dist/filter-chip/filter-chip.d.ts +21 -0
- package/dist/filter-chip/filter-chip.js +28 -0
- package/dist/filter-chip/index.d.ts +5 -0
- package/dist/filter-chip/index.js +6 -0
- package/dist/filter-strip/filter-strip.d.ts +12 -0
- package/dist/filter-strip/filter-strip.js +13 -0
- package/dist/filter-strip/index.d.ts +5 -0
- package/dist/filter-strip/index.js +6 -0
- package/dist/flash-word/flash-word.d.ts +31 -0
- package/dist/flash-word/flash-word.js +31 -0
- package/dist/flash-word/index.d.ts +5 -0
- package/dist/flash-word/index.js +9 -0
- package/dist/focus/focus.d.ts +15 -0
- package/dist/focus/focus.js +17 -0
- package/dist/focus/index.d.ts +5 -0
- package/dist/focus/index.js +9 -0
- package/dist/format/format.js +52 -0
- package/dist/format/index.d.ts +5 -0
- package/dist/format/index.js +6 -0
- package/dist/glyph/glyph.d.ts +9 -0
- package/dist/glyph/glyph.js +25 -0
- package/dist/glyph/glyphs.d.ts +381 -0
- package/dist/glyph/glyphs.js +2603 -0
- package/dist/glyph/index.d.ts +5 -0
- package/dist/glyph/index.js +6 -0
- package/dist/group/group.d.ts +8 -0
- package/dist/group/group.js +9 -0
- package/dist/group/index.d.ts +5 -0
- package/dist/group/index.js +6 -0
- package/dist/history/history.d.ts +34 -0
- package/dist/history/history.js +15 -0
- package/dist/history/index.d.ts +5 -0
- package/dist/history/index.js +6 -0
- package/dist/icon-button/icon-button.d.ts +23 -0
- package/dist/icon-button/icon-button.js +23 -0
- package/dist/icon-button/index.d.ts +5 -0
- package/dist/icon-button/index.js +6 -0
- package/dist/identity/identity.d.ts +15 -0
- package/dist/identity/identity.js +15 -0
- package/dist/identity/index.d.ts +5 -0
- package/dist/identity/index.js +6 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +85 -0
- package/dist/inline-input/index.d.ts +5 -0
- package/dist/inline-input/index.js +20 -0
- package/dist/inline-input/inline-input.d.ts +196 -0
- package/dist/inline-input/inline-input.js +212 -0
- package/dist/key-help/index.d.ts +5 -0
- package/dist/key-help/index.js +18 -0
- package/dist/key-help/key-help.d.ts +255 -0
- package/dist/key-help/key-help.js +137 -0
- package/dist/key-hint/index.d.ts +6 -0
- package/dist/key-hint/index.js +12 -0
- package/dist/key-hint/key-hint.d.ts +13 -0
- package/dist/key-hint/key-hint.js +7 -0
- package/dist/key-hint/key-label.d.ts +18 -0
- package/dist/key-hint/key-label.js +77 -0
- package/dist/keymap/keymap.d.ts +11 -0
- package/dist/keymap/keymap.js +9 -0
- package/dist/keys/keys.js +4 -0
- package/dist/line-diff/diff.d.ts +2 -0
- package/dist/line-diff/diff.js +73 -0
- package/dist/line-diff/index.d.ts +6 -0
- package/dist/line-diff/index.js +10 -0
- package/dist/line-diff/line-diff.d.ts +21 -0
- package/dist/line-diff/line-diff.js +75 -0
- package/dist/line-diff/patch.d.ts +15 -0
- package/dist/line-diff/patch.js +120 -0
- package/dist/link-button/index.d.ts +5 -0
- package/dist/link-button/index.js +6 -0
- package/dist/link-button/link-button.d.ts +11 -0
- package/dist/link-button/link-button.js +10 -0
- package/dist/link-state/index.d.ts +5 -0
- package/dist/link-state/index.js +6 -0
- package/dist/link-state/link-state.d.ts +15 -0
- package/dist/link-state/link-state.js +17 -0
- package/dist/live-region/index.d.ts +5 -0
- package/dist/live-region/index.js +9 -0
- package/dist/live-region/live-region.d.ts +39 -0
- package/dist/live-region/live-region.js +33 -0
- package/dist/loading/index.d.ts +5 -0
- package/dist/loading/index.js +6 -0
- package/dist/loading/loading.d.ts +19 -0
- package/dist/loading/loading.js +16 -0
- package/dist/locale/locale.d.ts +3 -0
- package/dist/locale/locale.js +5 -0
- package/dist/mark/index.d.ts +5 -0
- package/dist/mark/index.js +6 -0
- package/dist/mark/mark.d.ts +15 -0
- package/dist/mark/mark.js +30 -0
- package/dist/menu/index.d.ts +7 -0
- package/dist/menu/index.js +25 -0
- package/dist/menu/item.d.ts +236 -0
- package/dist/menu/item.js +19 -0
- package/dist/menu/menu.d.ts +206 -0
- package/dist/menu/menu.js +208 -0
- package/dist/menu/slip.js +163 -0
- package/dist/meter/index.d.ts +5 -0
- package/dist/meter/index.js +6 -0
- package/dist/meter/meter.d.ts +38 -0
- package/dist/meter/meter.js +69 -0
- package/dist/monogram/monogram.js +33 -0
- package/dist/nav-strip/index.d.ts +5 -0
- package/dist/nav-strip/index.js +6 -0
- package/dist/nav-strip/nav-strip.d.ts +19 -0
- package/dist/nav-strip/nav-strip.js +21 -0
- package/dist/notice/index.d.ts +5 -0
- package/dist/notice/index.js +6 -0
- package/dist/notice/notice.d.ts +23 -0
- package/dist/notice/notice.js +35 -0
- package/dist/outcome/index.d.ts +5 -0
- package/dist/outcome/index.js +6 -0
- package/dist/outcome/outcome.d.ts +19 -0
- package/dist/outcome/outcome.js +14 -0
- package/dist/page-head/index.d.ts +5 -0
- package/dist/page-head/index.js +6 -0
- package/dist/page-head/page-head.d.ts +13 -0
- package/dist/page-head/page-head.js +10 -0
- package/dist/panel/index.d.ts +5 -0
- package/dist/panel/index.js +6 -0
- package/dist/panel/panel.d.ts +35 -0
- package/dist/panel/panel.js +25 -0
- package/dist/password-field/index.d.ts +5 -0
- package/dist/password-field/index.js +6 -0
- package/dist/password-field/password-field.d.ts +33 -0
- package/dist/password-field/password-field.js +39 -0
- package/dist/places/index.d.ts +5 -0
- package/dist/places/index.js +6 -0
- package/dist/places/places.d.ts +32 -0
- package/dist/places/places.js +22 -0
- package/dist/props-list/index.d.ts +5 -0
- package/dist/props-list/index.js +6 -0
- package/dist/props-list/props-list.d.ts +18 -0
- package/dist/props-list/props-list.js +12 -0
- package/dist/prose/index.d.ts +5 -0
- package/dist/prose/index.js +6 -0
- package/dist/prose/prose.d.ts +14 -0
- package/dist/prose/prose.js +6 -0
- package/dist/query-chip/index.d.ts +5 -0
- package/dist/query-chip/index.js +6 -0
- package/dist/query-chip/query-chip.d.ts +18 -0
- package/dist/query-chip/query-chip.js +17 -0
- package/dist/radio-choices/index.d.ts +5 -0
- package/dist/radio-choices/index.js +12 -0
- package/dist/radio-choices/radio-choices.d.ts +105 -0
- package/dist/radio-choices/radio-choices.js +56 -0
- package/dist/rail/index.d.ts +5 -0
- package/dist/rail/index.js +22 -0
- package/dist/rail/rail.d.ts +403 -0
- package/dist/rail/rail.js +355 -0
- package/dist/reel/index.d.ts +6 -0
- package/dist/reel/index.js +26 -0
- package/dist/reel/layout.d.ts +58 -0
- package/dist/reel/layout.js +378 -0
- package/dist/reel/reel.d.ts +1070 -0
- package/dist/reel/reel.js +1019 -0
- package/dist/remote/index.d.ts +5 -0
- package/dist/remote/index.js +6 -0
- package/dist/remote/remote.d.ts +28 -0
- package/dist/remote/remote.js +41 -0
- package/dist/rows/index.d.ts +5 -0
- package/dist/rows/index.js +12 -0
- package/dist/rows/rows.d.ts +116 -0
- package/dist/rows/rows.js +67 -0
- package/dist/scheme/index.d.ts +6 -0
- package/dist/scheme/index.js +10 -0
- package/dist/scheme/scheme-switch.d.ts +98 -0
- package/dist/scheme/scheme-switch.js +118 -0
- package/dist/scheme/scheme.d.ts +5 -0
- package/dist/scheme/scheme.js +16 -0
- package/dist/scheme/script.d.ts +8 -0
- package/dist/scheme/script.js +10 -0
- package/dist/secret/index.d.ts +5 -0
- package/dist/secret/index.js +6 -0
- package/dist/secret/secret.d.ts +13 -0
- package/dist/secret/secret.js +9 -0
- package/dist/segmented/index.d.ts +5 -0
- package/dist/segmented/index.js +6 -0
- package/dist/segmented/segmented.d.ts +17 -0
- package/dist/segmented/segmented.js +17 -0
- package/dist/select-field/index.d.ts +5 -0
- package/dist/select-field/index.js +6 -0
- package/dist/select-field/select-field.d.ts +38 -0
- package/dist/select-field/select-field.js +29 -0
- package/dist/sheet/index.d.ts +5 -0
- package/dist/sheet/index.js +6 -0
- package/dist/sheet/sheet.d.ts +16 -0
- package/dist/sheet/sheet.js +15 -0
- package/dist/skip-link/index.d.ts +5 -0
- package/dist/skip-link/index.js +9 -0
- package/dist/skip-link/skip-link.d.ts +23 -0
- package/dist/skip-link/skip-link.js +36 -0
- package/dist/slot/slot.js +8 -0
- package/dist/sortable/index.d.ts +5 -0
- package/dist/sortable/index.js +16 -0
- package/dist/sortable/sortable.d.ts +1125 -0
- package/dist/sortable/sortable.js +431 -0
- package/dist/stack/index.d.ts +5 -0
- package/dist/stack/index.js +6 -0
- package/dist/stack/stack.d.ts +15 -0
- package/dist/stack/stack.js +12 -0
- package/dist/stage/index.d.ts +5 -0
- package/dist/stage/index.js +6 -0
- package/dist/stage/stage.d.ts +14 -0
- package/dist/stage/stage.js +11 -0
- package/dist/stat/index.d.ts +5 -0
- package/dist/stat/index.js +6 -0
- package/dist/stat/stat.d.ts +18 -0
- package/dist/stat/stat.js +13 -0
- package/dist/status-bar/index.d.ts +6 -0
- package/dist/status-bar/index.js +11 -0
- package/dist/status-bar/status-bar.d.ts +28 -0
- package/dist/status-bar/status-bar.js +19 -0
- package/dist/subscription/prefix-keys.js +12 -0
- package/dist/table/index.d.ts +5 -0
- package/dist/table/index.js +6 -0
- package/dist/table/table.d.ts +26 -0
- package/dist/table/table.js +18 -0
- package/dist/tabs/index.d.ts +5 -0
- package/dist/tabs/index.js +14 -0
- package/dist/tabs/tabs.d.ts +125 -0
- package/dist/tabs/tabs.js +57 -0
- package/dist/tag/index.d.ts +5 -0
- package/dist/tag/index.js +6 -0
- package/dist/tag/tag.d.ts +16 -0
- package/dist/tag/tag.js +25 -0
- package/dist/text-button/index.d.ts +5 -0
- package/dist/text-button/index.js +6 -0
- package/dist/text-button/text-button.d.ts +8 -0
- package/dist/text-button/text-button.js +12 -0
- package/dist/textarea-field/index.d.ts +5 -0
- package/dist/textarea-field/index.js +6 -0
- package/dist/textarea-field/textarea-field.d.ts +28 -0
- package/dist/textarea-field/textarea-field.js +30 -0
- package/dist/time/index.d.ts +5 -0
- package/dist/time/index.js +9 -0
- package/dist/time/time.d.ts +38 -0
- package/dist/time/time.js +63 -0
- package/dist/tips/index.d.ts +5 -0
- package/dist/tips/index.js +14 -0
- package/dist/tips/tips.d.ts +339 -0
- package/dist/tips/tips.js +308 -0
- package/dist/toast/index.d.ts +5 -0
- package/dist/toast/index.js +17 -0
- package/dist/toast/stack.d.ts +7 -0
- package/dist/toast/stack.js +23 -0
- package/dist/toast/toast.d.ts +559 -0
- package/dist/toast/toast.js +269 -0
- package/dist/toc/index.d.ts +5 -0
- package/dist/toc/index.js +9 -0
- package/dist/toc/toc.d.ts +42 -0
- package/dist/toc/toc.js +35 -0
- package/dist/top-bar/bar-height.d.ts +26 -0
- package/dist/top-bar/bar-height.js +43 -0
- package/dist/top-bar/index.d.ts +6 -0
- package/dist/top-bar/index.js +12 -0
- package/dist/top-bar/top-bar.d.ts +19 -0
- package/dist/top-bar/top-bar.js +18 -0
- package/dist/wall/index.d.ts +5 -0
- package/dist/wall/index.js +9 -0
- package/dist/wall/wall.d.ts +16 -0
- package/dist/wall/wall.js +15 -0
- package/dist/window/index.d.ts +5 -0
- package/dist/window/index.js +6 -0
- package/dist/window/window.d.ts +28 -0
- package/dist/window/window.js +29 -0
- package/dist/wordmark/index.d.ts +5 -0
- package/dist/wordmark/index.js +6 -0
- package/dist/wordmark/wordmark.d.ts +10 -0
- package/dist/wordmark/wordmark.js +10 -0
- package/dist/wrap/index.d.ts +5 -0
- package/dist/wrap/index.js +6 -0
- package/dist/wrap/wrap.d.ts +12 -0
- package/dist/wrap/wrap.js +9 -0
- package/fonts/DepartureMono-Regular.woff2 +0 -0
- package/fonts/LICENSE.txt +2 -0
- package/package.json +57 -3
- package/src/pixel-paper.css +4611 -0
- package/src/tokens.css +151 -0
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { view as view$1 } from "../glyph/glyph.js";
|
|
3
|
+
import { isPlain } from "../keys/keys.js";
|
|
4
|
+
import { view as view$2 } from "../icon-button/icon-button.js";
|
|
5
|
+
import { LOCALE } from "../locale/locale.js";
|
|
6
|
+
import { slotView } from "../slot/slot.js";
|
|
7
|
+
import { prefixKeys } from "../subscription/prefix-keys.js";
|
|
8
|
+
import { foldDialog } from "../dialog/fold.js";
|
|
9
|
+
import { Model as Model$1, OutMessage as OutMessage$1, dialog_exports, id as id$1, init as init$1, isOpen as isOpen$1, view as view$3 } from "../dialog/dialog.js";
|
|
10
|
+
import { Focus } from "../focus/focus.js";
|
|
11
|
+
import { Message } from "./message.js";
|
|
12
|
+
import { BindPaletteKeys, FIELD_ATTRIBUTE, OPTION_SELECTOR, PAGE_ATTRIBUTE, earlyKeys } from "./keys.js";
|
|
13
|
+
import { findCommands, pageChoices } from "./match.js";
|
|
14
|
+
import { Array, Effect, Equal, HashSet, Match, Option, Schema, Stream, String, pipe } from "effect";
|
|
15
|
+
import * as FoldkitCommand from "foldkit/command";
|
|
16
|
+
import { defineMessageUnion } from "foldkit/message";
|
|
17
|
+
import * as Render from "foldkit/render";
|
|
18
|
+
import { Input } from "@foldkit/ui";
|
|
19
|
+
import { modifyFields } from "foldkit/struct";
|
|
20
|
+
import { defineView } from "foldkit/submodel";
|
|
21
|
+
import * as Subscription from "foldkit/subscription";
|
|
22
|
+
import * as Update from "foldkit/update";
|
|
23
|
+
import * as Dom from "foldkit/dom";
|
|
24
|
+
// src/command-palette/command-palette.ts
|
|
25
|
+
const OpenPage = Schema.Struct({
|
|
26
|
+
commandId: Schema.String,
|
|
27
|
+
query: Schema.String,
|
|
28
|
+
maybeCursor: Schema.Option(Schema.String)
|
|
29
|
+
});
|
|
30
|
+
/** Schema for a command palette: its Dialog, the commands' query and cursor (kept while a
|
|
31
|
+
* page is open, so Back restores them), the open page, and the choice being picked. A cursor
|
|
32
|
+
* is a row's id, so it holds to its row while the list changes. The rows are the view's
|
|
33
|
+
* (built from its `commands`), so ↑, ↓ and Enter carry what their render showed: its rows,
|
|
34
|
+
* the row it showed the cursor on, and the query and waiting arrows it was rendered with.
|
|
35
|
+
* When that query is the Model's and the render had applied the waiting arrows, those rows
|
|
36
|
+
* are the list, and update steps among them from the Model's cursor. A key pressed before the
|
|
37
|
+
* view caught up (as the palette opens, or just after typing, while the list still shows the
|
|
38
|
+
* last query's rows) cannot name a row yet: `cursorShift` counts the arrows, which the next
|
|
39
|
+
* render applies from the cursor's row, and `isEnterPending` an Enter. Such a key returns
|
|
40
|
+
* `ReportPendingKeys`, which reads the row the next render shows the cursor on: it becomes
|
|
41
|
+
* the cursor, and a waiting Enter acts on it. `renderGeneration` counts the changes to the
|
|
42
|
+
* page, the query and the waiting arrows, so a report from an older render is refused. */
|
|
43
|
+
const Model = Schema.Struct({
|
|
44
|
+
dialog: Model$1,
|
|
45
|
+
query: Schema.String,
|
|
46
|
+
maybeCursor: Schema.Option(Schema.String),
|
|
47
|
+
cursorShift: Schema.Finite,
|
|
48
|
+
isEnterPending: Schema.Boolean,
|
|
49
|
+
renderGeneration: Schema.Int,
|
|
50
|
+
maybePage: Schema.Option(OpenPage),
|
|
51
|
+
maybePicking: Schema.Option(Schema.String)
|
|
52
|
+
});
|
|
53
|
+
/** Union of OutMessages a command palette reports. `SelectedCommand`: run this command; the
|
|
54
|
+
* palette has closed first, so what it opens takes focus. `SelectedChoice`: apply this choice
|
|
55
|
+
* of that command's page; the page holds, the row printing the working cursor, until the
|
|
56
|
+
* caller reports back with `pickSucceeded` or `pickFailed`. `Closed`: the reader dismissed
|
|
57
|
+
* the palette (Escape, a press on the veil), even while a pick was out; a write already
|
|
58
|
+
* running keeps running, and its answer no longer changes the palette. */
|
|
59
|
+
const OutMessage = defineMessageUnion({
|
|
60
|
+
SelectedCommand: { id: Schema.String },
|
|
61
|
+
SelectedChoice: {
|
|
62
|
+
commandId: Schema.String,
|
|
63
|
+
choiceId: Schema.String
|
|
64
|
+
},
|
|
65
|
+
Closed: {}
|
|
66
|
+
});
|
|
67
|
+
const fieldId = (paletteId) => __foldkitBrandViewResult((`${paletteId}-field`), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#fieldId");
|
|
68
|
+
const listIdOf = (paletteId) => __foldkitBrandViewResult((`${paletteId}-list`), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#listIdOf");
|
|
69
|
+
/** Creates a closed command palette. */
|
|
70
|
+
const init = (config) => (__foldkitBrandViewResult(({
|
|
71
|
+
dialog: init$1({ id: config.id }),
|
|
72
|
+
query: "",
|
|
73
|
+
maybeCursor: Option.none(),
|
|
74
|
+
cursorShift: 0,
|
|
75
|
+
isEnterPending: false,
|
|
76
|
+
renderGeneration: 0,
|
|
77
|
+
maybePage: Option.none(),
|
|
78
|
+
maybePicking: Option.none()
|
|
79
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#init"));
|
|
80
|
+
/** The palette's id, unique in the document. */
|
|
81
|
+
const id = (model) => __foldkitBrandViewResult((id$1(model.dialog)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#id");
|
|
82
|
+
/** Whether the palette is open. */
|
|
83
|
+
const isOpen = (model) => __foldkitBrandViewResult((isOpen$1(model.dialog)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#isOpen");
|
|
84
|
+
/** The words in the field: the open page's, or the commands'. A page whose choices are a
|
|
85
|
+
* function of what is typed reads it here. */
|
|
86
|
+
const query = (model) => __foldkitBrandViewResult((Option.match(model.maybePage, {
|
|
87
|
+
onNone: () => __foldkitBrandViewResult((model.query), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone"),
|
|
88
|
+
onSome: (page) => __foldkitBrandViewResult((page.query), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome")
|
|
89
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#query");
|
|
90
|
+
/** The command whose page is open. */
|
|
91
|
+
const maybePageId = (model) => __foldkitBrandViewResult((Option.map(model.maybePage, (page) => __foldkitBrandViewResult((page.commandId), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybePageId");
|
|
92
|
+
/** Whether a picked choice is waiting for the caller's answer. */
|
|
93
|
+
const isPicking = (model) => __foldkitBrandViewResult((Option.isSome(model.maybePicking)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#isPicking");
|
|
94
|
+
const ROW_ATTRIBUTE = "value";
|
|
95
|
+
const OPENS_PAGE_ATTRIBUTE = "pixel-paper-palette-opens-page";
|
|
96
|
+
/**
|
|
97
|
+
* Scrolls the cursor's row of the palette `paletteId` (its `id`) into view by the least
|
|
98
|
+
* distance, once the view has rendered. The palette returns it itself as the cursor moves, the
|
|
99
|
+
* query changes or a page opens; an application returns it too when the rows change under an
|
|
100
|
+
* open palette (see `maybeCursorId`), or as it opens one on a page whose cursor may be far
|
|
101
|
+
* down, and resolves it with `Message.CompletedScrollToCursor` in a Scene.
|
|
102
|
+
*/
|
|
103
|
+
const ScrollToCursor = FoldkitCommand.define("ScrollToCursor", {
|
|
104
|
+
args: { paletteId: Schema.String },
|
|
105
|
+
messages: [Message.CompletedScrollToCursor],
|
|
106
|
+
execute: ({ paletteId }) => __foldkitBrandViewResult((Effect.suspend(() => __foldkitBrandViewResult((Dom.scrollIntoView(`#${CSS.escape(listIdOf(paletteId))} [aria-selected="true"]`)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~2")).pipe(Effect.ignore, Effect.as(Message.CompletedScrollToCursor()))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#execute")
|
|
107
|
+
});
|
|
108
|
+
const shownRowOf = (row) => __foldkitBrandViewResult((Option.map(Option.fromNullishOr(row.getAttribute(`data-${ROW_ATTRIBUTE}`)), (rowId) => (__foldkitBrandViewResult(({
|
|
109
|
+
id: rowId,
|
|
110
|
+
isHeld: row.getAttribute("aria-disabled") === "true",
|
|
111
|
+
hasPage: row.hasAttribute(`data-${OPENS_PAGE_ATTRIBUTE}`)
|
|
112
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~3")))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#shownRowOf");
|
|
113
|
+
const find = (selector) => __foldkitBrandViewResult((Option.fromNullishOr(document.querySelector(selector))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#find");
|
|
114
|
+
const shownCursorOf = (paletteId) => __foldkitBrandViewResult((Option.flatMap(find(`#${CSS.escape(listIdOf(paletteId))} ${OPTION_SELECTOR}[aria-selected="true"]`), shownRowOf)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#shownCursorOf");
|
|
115
|
+
/** Reads, once the next render has committed, the row it shows the cursor on while keys wait
|
|
116
|
+
* for it (see `Model`), with the Model's `renderGeneration` as they waited, so update knows
|
|
117
|
+
* whether that render is still the list. The palette's update returns it as a key waits; in
|
|
118
|
+
* a Scene, resolve it with `Message.CompletedReportPendingKeys`. */
|
|
119
|
+
const ReportPendingKeys = FoldkitCommand.define("ReportPendingKeys", {
|
|
120
|
+
args: {
|
|
121
|
+
paletteId: Schema.String,
|
|
122
|
+
renderGeneration: Schema.Int
|
|
123
|
+
},
|
|
124
|
+
messages: [Message.CompletedReportPendingKeys],
|
|
125
|
+
execute: ({ paletteId, renderGeneration }) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
126
|
+
yield* Render.afterCommit;
|
|
127
|
+
const maybeRow = yield* Effect.sync(() => __foldkitBrandViewResult((shownCursorOf(paletteId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~5"));
|
|
128
|
+
return __foldkitBrandViewResult((Message.CompletedReportPendingKeys({
|
|
129
|
+
renderGeneration,
|
|
130
|
+
maybeRow
|
|
131
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~4");
|
|
132
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#execute~2")
|
|
133
|
+
});
|
|
134
|
+
const scrollPaletteToCursor = (model) => __foldkitBrandViewResult((ScrollToCursor({ paletteId: id(model) })), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#scrollPaletteToCursor");
|
|
135
|
+
const reportPendingKeys = (model) => __foldkitBrandViewResult((ReportPendingKeys({
|
|
136
|
+
paletteId: id(model),
|
|
137
|
+
renderGeneration: model.renderGeneration
|
|
138
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#reportPendingKeys");
|
|
139
|
+
const focusField = (model) => __foldkitBrandViewResult((Focus({ id: fieldId(id(model)) })), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#focusField");
|
|
140
|
+
const toClosed = OutMessage$1.match({ Closed: () => __foldkitBrandViewResult((OutMessage.Closed()), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#Closed") });
|
|
141
|
+
const dialogFold = foldDialog(dialog_exports, {
|
|
142
|
+
read: (model) => __foldkitBrandViewResult((model.dialog), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#read"),
|
|
143
|
+
write: (model, nextDialog) => __foldkitBrandViewResult((modifyFields(model, { dialog: () => __foldkitBrandViewResult((nextDialog), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#dialog") })), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#write"),
|
|
144
|
+
toParentMessage: (message) => __foldkitBrandViewResult((Message.GotDialogMessage({ message })), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#toParentMessage"),
|
|
145
|
+
toParentOutMessage: toClosed
|
|
146
|
+
});
|
|
147
|
+
const freshPage = (commandId) => (__foldkitBrandViewResult(({
|
|
148
|
+
commandId,
|
|
149
|
+
query: "",
|
|
150
|
+
maybeCursor: Option.none()
|
|
151
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#freshPage"));
|
|
152
|
+
const nextGeneration = (generation) => __foldkitBrandViewResult((generation + 1), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#nextGeneration");
|
|
153
|
+
const clearPendingKeys = (model) => __foldkitBrandViewResult((modifyFields(model, {
|
|
154
|
+
cursorShift: () => __foldkitBrandViewResult((0), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#cursorShift"),
|
|
155
|
+
isEnterPending: () => __foldkitBrandViewResult((false), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#isEnterPending"),
|
|
156
|
+
renderGeneration: nextGeneration
|
|
157
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#clearPendingKeys");
|
|
158
|
+
const fresh = (model, maybePage) => __foldkitBrandViewResult((clearPendingKeys(modifyFields(model, {
|
|
159
|
+
query: () => __foldkitBrandViewResult((""), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#query~2"),
|
|
160
|
+
maybeCursor: () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybeCursor"),
|
|
161
|
+
maybePage: () => __foldkitBrandViewResult((maybePage), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybePage"),
|
|
162
|
+
maybePicking: () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybePicking")
|
|
163
|
+
}))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#fresh");
|
|
164
|
+
const followShown = (model, maybeShownPage) => __foldkitBrandViewResult((Equal.equals(maybePageId(model), maybeShownPage) ? model : clearPendingKeys(modifyFields(model, {
|
|
165
|
+
maybePage: () => __foldkitBrandViewResult((Option.map(maybeShownPage, freshPage)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybePage~2"),
|
|
166
|
+
maybePicking: () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybePicking~2")
|
|
167
|
+
}))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#followShown");
|
|
168
|
+
const modifyPage = (model, modifyOpenPage) => __foldkitBrandViewResult((modifyFields(model, { maybePage: Option.map(modifyOpenPage) })), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#modifyPage");
|
|
169
|
+
const unlessPicking = (model, next) => __foldkitBrandViewResult((isPicking(model) ? { model } : next(model)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#unlessPicking");
|
|
170
|
+
const leavePage = (model) => __foldkitBrandViewResult((isPicking(model) || Option.isNone(model.maybePage) ? { model } : {
|
|
171
|
+
model: clearPendingKeys(modifyFields(model, { maybePage: () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybePage~3") })),
|
|
172
|
+
commands: [focusField(model), scrollPaletteToCursor(model)]
|
|
173
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#leavePage");
|
|
174
|
+
const openPage = (model, commandId) => (__foldkitBrandViewResult(({
|
|
175
|
+
model: clearPendingKeys(modifyFields(model, { maybePage: () => __foldkitBrandViewResult((Option.some(freshPage(commandId))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybePage~4") })),
|
|
176
|
+
commands: [focusField(model), scrollPaletteToCursor(model)]
|
|
177
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#openPage"));
|
|
178
|
+
const selectCommand = (model, commandId) => __foldkitBrandViewResult((pipe(dialogFold.close(model), Update.withOutMessage(OutMessage.SelectedCommand({ id: commandId })))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#selectCommand");
|
|
179
|
+
const moveCursor = (model, cursorId) => __foldkitBrandViewResult((modifyFields(Option.match(model.maybePage, {
|
|
180
|
+
onNone: () => __foldkitBrandViewResult((modifyFields(model, { maybeCursor: () => __foldkitBrandViewResult((Option.some(cursorId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybeCursor~2") })), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~2"),
|
|
181
|
+
onSome: () => __foldkitBrandViewResult((modifyPage(model, (page) => __foldkitBrandViewResult((modifyFields(page, { maybeCursor: () => __foldkitBrandViewResult((Option.some(cursorId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybeCursor~3") })), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~6"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~2")
|
|
182
|
+
}), {
|
|
183
|
+
cursorShift: () => __foldkitBrandViewResult((0), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#cursorShift~2"),
|
|
184
|
+
renderGeneration: nextGeneration
|
|
185
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#moveCursor");
|
|
186
|
+
const pick = (model, commandId, choiceId) => (__foldkitBrandViewResult(({
|
|
187
|
+
model: clearPendingKeys(modifyFields(moveCursor(model, choiceId), { maybePicking: () => __foldkitBrandViewResult((Option.some(choiceId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybePicking~3") })),
|
|
188
|
+
outMessage: OutMessage.SelectedChoice({
|
|
189
|
+
commandId,
|
|
190
|
+
choiceId
|
|
191
|
+
})
|
|
192
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#pick"));
|
|
193
|
+
const runRow = (model, row) => {
|
|
194
|
+
if (row.isHeld) return __foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#runRow");
|
|
195
|
+
return __foldkitBrandViewResult((Option.match(maybePageId(model), {
|
|
196
|
+
onSome: (commandId) => __foldkitBrandViewResult((pick(model, commandId, row.id)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~3"),
|
|
197
|
+
onNone: () => __foldkitBrandViewResult((row.hasPage ? openPage(model, row.id) : selectCommand(model, row.id)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~3")
|
|
198
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#runRow");
|
|
199
|
+
};
|
|
200
|
+
const maybeCurrentCursor = (model) => __foldkitBrandViewResult((Option.match(model.maybePage, {
|
|
201
|
+
onNone: () => __foldkitBrandViewResult((model.maybeCursor), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~4"),
|
|
202
|
+
onSome: (page) => __foldkitBrandViewResult((page.maybeCursor), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~4")
|
|
203
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybeCurrentCursor");
|
|
204
|
+
const ARROW_STEP = {
|
|
205
|
+
ArrowUp: -1,
|
|
206
|
+
ArrowDown: 1
|
|
207
|
+
};
|
|
208
|
+
const isListed = (rows, rowId) => __foldkitBrandViewResult((Array.some(rows, (row) => __foldkitBrandViewResult((row.id === rowId), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~7"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#isListed");
|
|
209
|
+
const cursorAsShown = (model, shown) => {
|
|
210
|
+
const { rows, maybeShownCursor, shownQuery, shownShift } = shown;
|
|
211
|
+
const isTheList = shownQuery === query(model);
|
|
212
|
+
const hasNoWaitingArrows = model.cursorShift === 0;
|
|
213
|
+
const hasAppliedWaitingArrows = shownShift === model.cursorShift;
|
|
214
|
+
if (isTheList && hasNoWaitingArrows) return __foldkitBrandViewResult((Option.match(Option.filter(maybeCurrentCursor(model), (rowId) => __foldkitBrandViewResult((isListed(rows, rowId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~8")), {
|
|
215
|
+
onSome: (rowId) => (__foldkitBrandViewResult(({
|
|
216
|
+
_tag: "Listed",
|
|
217
|
+
rowId
|
|
218
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~5")),
|
|
219
|
+
onNone: () => (__foldkitBrandViewResult(({
|
|
220
|
+
_tag: "Shown",
|
|
221
|
+
maybeRowId: maybeShownCursor
|
|
222
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~5"))
|
|
223
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#cursorAsShown");
|
|
224
|
+
else if (isTheList && hasAppliedWaitingArrows) return __foldkitBrandViewResult(({
|
|
225
|
+
_tag: "Shown",
|
|
226
|
+
maybeRowId: maybeShownCursor
|
|
227
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#cursorAsShown");
|
|
228
|
+
return __foldkitBrandViewResult(({ _tag: "Waiting" }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#cursorAsShown");
|
|
229
|
+
};
|
|
230
|
+
const stepTo = (model, rowId) => {
|
|
231
|
+
const moved = moveCursor(model, rowId);
|
|
232
|
+
return __foldkitBrandViewResult(({
|
|
233
|
+
model: moved,
|
|
234
|
+
commands: [scrollPaletteToCursor(model), ...moved.isEnterPending ? [reportPendingKeys(moved)] : []]
|
|
235
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#stepTo");
|
|
236
|
+
};
|
|
237
|
+
const rowAfter = (rows, maybeFrom, steps) => __foldkitBrandViewResult((pipe(maybeFrom, Option.flatMap((rowId) => __foldkitBrandViewResult((Array.findFirstIndex(rows, (row) => __foldkitBrandViewResult((row.id === rowId), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~10"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~9")), Option.flatMap((index) => __foldkitBrandViewResult((Array.get(rows, Math.min(Math.max(index + steps, 0), rows.length - 1))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~11")))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#rowAfter");
|
|
238
|
+
const stepFrom = (model, key, rows, maybeFrom) => __foldkitBrandViewResult((Option.match(rowAfter(rows, maybeFrom, ARROW_STEP[key]), {
|
|
239
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~6")),
|
|
240
|
+
onSome: (row) => __foldkitBrandViewResult((stepTo(model, row.id)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~6")
|
|
241
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#stepFrom");
|
|
242
|
+
const pendArrow = (model, key) => {
|
|
243
|
+
const pending = modifyFields(model, {
|
|
244
|
+
cursorShift: (shift) => __foldkitBrandViewResult((shift + ARROW_STEP[key]), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#cursorShift~3"),
|
|
245
|
+
renderGeneration: nextGeneration
|
|
246
|
+
});
|
|
247
|
+
return __foldkitBrandViewResult(({
|
|
248
|
+
model: pending,
|
|
249
|
+
commands: [scrollPaletteToCursor(model), reportPendingKeys(pending)]
|
|
250
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#pendArrow");
|
|
251
|
+
};
|
|
252
|
+
const pressArrow = (model, key, shown) => __foldkitBrandViewResult((Match.valueTags(cursorAsShown(model, shown), {
|
|
253
|
+
Listed: ({ rowId }) => __foldkitBrandViewResult((stepFrom(model, key, shown.rows, Option.some(rowId))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#Listed"),
|
|
254
|
+
Shown: ({ maybeRowId }) => __foldkitBrandViewResult((stepFrom(model, key, shown.rows, maybeRowId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#Shown"),
|
|
255
|
+
Waiting: () => __foldkitBrandViewResult((pendArrow(model, key)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#Waiting")
|
|
256
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#pressArrow");
|
|
257
|
+
const pendEnter = (model) => {
|
|
258
|
+
const pending = modifyFields(model, { isEnterPending: () => __foldkitBrandViewResult((true), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#isEnterPending~2") });
|
|
259
|
+
return __foldkitBrandViewResult(({
|
|
260
|
+
model: pending,
|
|
261
|
+
commands: [reportPendingKeys(pending)]
|
|
262
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#pendEnter");
|
|
263
|
+
};
|
|
264
|
+
const enterOn = (model, rows, maybeRowId) => __foldkitBrandViewResult((pipe(maybeRowId, Option.flatMap((rowId) => __foldkitBrandViewResult((Array.findFirst(rows, (row) => __foldkitBrandViewResult((row.id === rowId), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~13"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~12")), Option.match({
|
|
265
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~7")),
|
|
266
|
+
onSome: (row) => __foldkitBrandViewResult((runRow(model, row)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~7")
|
|
267
|
+
}))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#enterOn");
|
|
268
|
+
const pressEnter = (model, shown) => __foldkitBrandViewResult((Match.valueTags(cursorAsShown(model, shown), {
|
|
269
|
+
Listed: ({ rowId }) => __foldkitBrandViewResult((enterOn(model, shown.rows, Option.some(rowId))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#Listed~2"),
|
|
270
|
+
Shown: ({ maybeRowId }) => __foldkitBrandViewResult((enterOn(model, shown.rows, maybeRowId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#Shown~2"),
|
|
271
|
+
Waiting: () => __foldkitBrandViewResult((pendEnter(model)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#Waiting~2")
|
|
272
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#pressEnter");
|
|
273
|
+
const isPending = (model) => __foldkitBrandViewResult((model.cursorShift !== 0 || model.isEnterPending), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#isPending");
|
|
274
|
+
const settlePending = (model, report) => {
|
|
275
|
+
if (!isPending(model) || report.renderGeneration !== model.renderGeneration) return __foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#settlePending");
|
|
276
|
+
const settled = clearPendingKeys(model);
|
|
277
|
+
return __foldkitBrandViewResult((Option.match(report.maybeRow, {
|
|
278
|
+
onNone: () => (__foldkitBrandViewResult(({ model: settled }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~8")),
|
|
279
|
+
onSome: (row) => {
|
|
280
|
+
const moved = moveCursor(settled, row.id);
|
|
281
|
+
const ran = model.isEnterPending ? runRow(moved, row) : { model: moved };
|
|
282
|
+
return __foldkitBrandViewResult(({
|
|
283
|
+
...ran,
|
|
284
|
+
commands: [scrollPaletteToCursor(model), ...ran.commands ?? []]
|
|
285
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~8");
|
|
286
|
+
}
|
|
287
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#settlePending");
|
|
288
|
+
};
|
|
289
|
+
const updateQuery = (model, value) => __foldkitBrandViewResult((clearPendingKeys(Option.match(model.maybePage, {
|
|
290
|
+
onNone: () => __foldkitBrandViewResult((modifyFields(model, {
|
|
291
|
+
query: () => __foldkitBrandViewResult((value), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#query~3"),
|
|
292
|
+
maybeCursor: () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybeCursor~4")
|
|
293
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~9"),
|
|
294
|
+
onSome: () => __foldkitBrandViewResult((modifyPage(model, (page) => __foldkitBrandViewResult((modifyFields(page, {
|
|
295
|
+
query: () => __foldkitBrandViewResult((value), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#query~4"),
|
|
296
|
+
maybeCursor: () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybeCursor~5")
|
|
297
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~14"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~9")
|
|
298
|
+
}))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#updateQuery");
|
|
299
|
+
/** Processes a command palette Message and returns the next Model, Commands and OutMessage. */
|
|
300
|
+
const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
301
|
+
GotDialogMessage: ({ message: dialogMessage }) => __foldkitBrandViewResult((dialogFold.update(model, dialogMessage)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#GotDialogMessage"),
|
|
302
|
+
UpdatedQuery: ({ value, maybeShownPage }) => __foldkitBrandViewResult((unlessPicking(followShown(model, maybeShownPage), (shown) => (__foldkitBrandViewResult(({
|
|
303
|
+
model: updateQuery(shown, value),
|
|
304
|
+
commands: [scrollPaletteToCursor(shown)]
|
|
305
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~15")))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#UpdatedQuery"),
|
|
306
|
+
PressedArrowKey: ({ key, snapshot }) => __foldkitBrandViewResult((unlessPicking(followShown(model, snapshot.maybeShownPage), (current) => __foldkitBrandViewResult((pressArrow(current, key, snapshot)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~16"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#PressedArrowKey"),
|
|
307
|
+
PressedEarlyArrowKey: ({ key }) => __foldkitBrandViewResult((unlessPicking(model, (current) => __foldkitBrandViewResult((pendArrow(current, key)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~17"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#PressedEarlyArrowKey"),
|
|
308
|
+
CompletedReportPendingKeys: (report) => __foldkitBrandViewResult((settlePending(model, report)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#CompletedReportPendingKeys"),
|
|
309
|
+
PressedEnter: ({ snapshot }) => __foldkitBrandViewResult((unlessPicking(followShown(model, snapshot.maybeShownPage), (current) => __foldkitBrandViewResult((pressEnter(current, snapshot)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~18"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#PressedEnter"),
|
|
310
|
+
PressedEarlyEnter: () => __foldkitBrandViewResult((unlessPicking(model, pendEnter)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#PressedEarlyEnter"),
|
|
311
|
+
PressedBackspace: ({ maybeShownPage }) => __foldkitBrandViewResult((leavePage(followShown(model, maybeShownPage))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#PressedBackspace"),
|
|
312
|
+
ClickedRow: ({ row, maybeShownPage }) => __foldkitBrandViewResult((unlessPicking(followShown(model, maybeShownPage), (current) => __foldkitBrandViewResult((runRow(current, row)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~19"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#ClickedRow"),
|
|
313
|
+
ClickedBack: () => __foldkitBrandViewResult((leavePage(model)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#ClickedBack"),
|
|
314
|
+
CompletedScrollToCursor: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#CompletedScrollToCursor")),
|
|
315
|
+
CompletedFocus: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#CompletedFocus"))
|
|
316
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#update");
|
|
317
|
+
/** Opens the palette on the commands, with an empty field and the cursor on the first row.
|
|
318
|
+
* Snapshot what the commands act on (the selected item, its title for `scope`) in the
|
|
319
|
+
* caller's Model as it opens, and build `commands` from that snapshot until it closes. */
|
|
320
|
+
const open = (model) => __foldkitBrandViewResult((dialogFold.open(fresh(model, Option.none()))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#open");
|
|
321
|
+
/** Opens the palette straight on a command's page. Back still leads to the commands. */
|
|
322
|
+
const openAt = (model, config) => __foldkitBrandViewResult((dialogFold.open(fresh(model, Option.some(freshPage(config.commandId))))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#openAt");
|
|
323
|
+
/** The caller applied the choice: the palette closes. An answer for a pick that is no longer
|
|
324
|
+
* out (the palette was dismissed, its page left, or a newer pick replaced it) changes
|
|
325
|
+
* nothing; the caller keeps the write it made. */
|
|
326
|
+
const pickSucceeded = (model, choiceId) => __foldkitBrandViewResult((Option.contains(model.maybePicking, choiceId) ? dialogFold.close(fresh(model, Option.none())) : { model }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#pickSucceeded");
|
|
327
|
+
/** The caller refused the choice: the page stays with its query, focus and the cursor on that
|
|
328
|
+
* choice; say why in the view's `toDetailView`. An answer for a pick that is no longer out
|
|
329
|
+
* changes nothing. */
|
|
330
|
+
const pickFailed = (model, choiceId) => __foldkitBrandViewResult((Option.contains(model.maybePicking, choiceId) ? { model: modifyFields(model, { maybePicking: () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybePicking~4") }) } : { model }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#pickFailed");
|
|
331
|
+
const earlyKeySubscriptions = Subscription.make()((entry) => (__foldkitBrandViewResult(({ earlyKeys: entry({ maybeOpenId: Schema.Option(Schema.String) }, {
|
|
332
|
+
modelToDependencies: (model) => (__foldkitBrandViewResult(({ maybeOpenId: isOpen(model) ? Option.some(id(model)) : Option.none() }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#modelToDependencies")),
|
|
333
|
+
dependenciesToStream: ({ maybeOpenId }) => __foldkitBrandViewResult((Option.match(maybeOpenId, {
|
|
334
|
+
onNone: () => __foldkitBrandViewResult((Stream.empty), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~10"),
|
|
335
|
+
onSome: earlyKeys
|
|
336
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#dependenciesToStream")
|
|
337
|
+
}) }), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~20")));
|
|
338
|
+
/** While the palette is open, takes ↑ ↓ and Enter pressed before its field has focus (the
|
|
339
|
+
* field's own are the view's), on the window, before the page's own key bindings see them,
|
|
340
|
+
* so the keys pressed straight after the one that opened it are not lost. Lift it into the
|
|
341
|
+
* application's Subscriptions, once per palette, with a key prefix of the parent's that no
|
|
342
|
+
* other record on the page uses: `subscriptions("palette")` is keyed `paletteEarlyKeys`. */
|
|
343
|
+
const subscriptions = (keyPrefix) => __foldkitBrandViewResult((prefixKeys(keyPrefix, earlyKeySubscriptions)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#subscriptions");
|
|
344
|
+
const pageOf = (commands, state) => __foldkitBrandViewResult((pipe(Array.findFirst(commands, (command) => __foldkitBrandViewResult((command.id === state.commandId), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~21")), Option.flatMap((command) => __foldkitBrandViewResult((Option.fromNullishOr(command.page)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~22")), Option.map((page) => (__foldkitBrandViewResult(({
|
|
345
|
+
page,
|
|
346
|
+
state
|
|
347
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~23"))))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#pageOf");
|
|
348
|
+
const firstListed = (rows, candidates) => __foldkitBrandViewResult((Array.findFirst(Array.getSomes(candidates), (cursorId) => __foldkitBrandViewResult((isListed(rows, cursorId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~24"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#firstListed");
|
|
349
|
+
const firstId = (rows) => __foldkitBrandViewResult((Option.map(Array.head(rows), (row) => __foldkitBrandViewResult((row.id), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~25"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#firstId");
|
|
350
|
+
const cursorRowFallback = ({ maybeMovedTo, rows, found, pageDefaults }) => __foldkitBrandViewResult((pipe(Option.filter(maybeMovedTo, (rowId) => __foldkitBrandViewResult((isListed(rows, rowId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~26")), Option.orElse(() => __foldkitBrandViewResult((firstListed(found, pageDefaults)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~27")), Option.orElse(() => __foldkitBrandViewResult((firstId(found)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~28")))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#cursorRowFallback");
|
|
351
|
+
const shifted = (shown, shift) => (__foldkitBrandViewResult(({
|
|
352
|
+
...shown,
|
|
353
|
+
maybeCursorId: Option.map(rowAfter(shown.rows, shown.maybeCursorId, shift), (row) => __foldkitBrandViewResult((row.id), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~29"))
|
|
354
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#shifted"));
|
|
355
|
+
const unshiftedOf = (model, commands) => {
|
|
356
|
+
const maybePage = Option.flatMap(model.maybePage, (state) => __foldkitBrandViewResult((pageOf(commands, state)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~30"));
|
|
357
|
+
return __foldkitBrandViewResult((Option.match(maybePage, {
|
|
358
|
+
onNone: () => {
|
|
359
|
+
const rows = findCommands(commands, model.query);
|
|
360
|
+
return __foldkitBrandViewResult(({
|
|
361
|
+
maybePage,
|
|
362
|
+
rows,
|
|
363
|
+
contextIds: HashSet.empty(),
|
|
364
|
+
maybeCursorId: cursorRowFallback({
|
|
365
|
+
maybeMovedTo: model.maybeCursor,
|
|
366
|
+
rows,
|
|
367
|
+
found: rows,
|
|
368
|
+
pageDefaults: []
|
|
369
|
+
})
|
|
370
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~11");
|
|
371
|
+
},
|
|
372
|
+
onSome: ({ page, state }) => {
|
|
373
|
+
const { rows, found, contextIds } = pageChoices(page, state.query);
|
|
374
|
+
return __foldkitBrandViewResult(({
|
|
375
|
+
maybePage,
|
|
376
|
+
rows,
|
|
377
|
+
contextIds,
|
|
378
|
+
maybeCursorId: cursorRowFallback({
|
|
379
|
+
maybeMovedTo: state.maybeCursor,
|
|
380
|
+
rows,
|
|
381
|
+
found,
|
|
382
|
+
pageDefaults: [Option.fromNullishOr(page.start), Option.fromNullishOr(page.current)]
|
|
383
|
+
})
|
|
384
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~10");
|
|
385
|
+
}
|
|
386
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#unshiftedOf");
|
|
387
|
+
};
|
|
388
|
+
const hasCursorRowLeft = (model, unshifted) => __foldkitBrandViewResult((Option.exists(maybeCurrentCursor(model), (rowId) => __foldkitBrandViewResult((!Option.contains(unshifted.maybeCursorId, rowId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~31"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#hasCursorRowLeft");
|
|
389
|
+
const dropArrowsWhenCursorRowGone = (model, unshifted) => __foldkitBrandViewResult((hasCursorRowLeft(model, unshifted) ? unshifted : shifted(unshifted, model.cursorShift)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#dropArrowsWhenCursorRowGone");
|
|
390
|
+
const shownOf = (model, commands) => __foldkitBrandViewResult((dropArrowsWhenCursorRowGone(model, unshiftedOf(model, commands))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#shownOf");
|
|
391
|
+
/** The row the cursor is on as the view shows it with `commands`: the row the reader moved it
|
|
392
|
+
* to while that row is listed, else the page's `start` or `current` while the query finds it,
|
|
393
|
+
* else the first row the query finds; none when nothing is listed. Compare it before and after
|
|
394
|
+
* the caller's commands change to know when the cursor fell to another row (its row left) and
|
|
395
|
+
* should be scrolled into view with `ScrollToCursor`; a cursor whose row is still listed keeps
|
|
396
|
+
* it, and the list its scroll. */
|
|
397
|
+
const maybeCursorId = (model, commands) => __foldkitBrandViewResult((shownOf(model, commands).maybeCursorId), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#maybeCursorId");
|
|
398
|
+
const isCommand = (row) => __foldkitBrandViewResult(("group" in row), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#isCommand");
|
|
399
|
+
const isCurrentRow = (shown, row) => __foldkitBrandViewResult((Option.exists(shown.maybePage, ({ page }) => __foldkitBrandViewResult((page.current === row.id), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~32"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#isCurrentRow");
|
|
400
|
+
const isContextRow = (shown, row) => __foldkitBrandViewResult((HashSet.has(shown.contextIds, row.id)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#isContextRow");
|
|
401
|
+
const levelOf = (row) => __foldkitBrandViewResult(("level" in row ? Option.fromNullishOr(row.level) : Option.none()), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#levelOf");
|
|
402
|
+
const shownRowFor = (shown, row) => (__foldkitBrandViewResult(({
|
|
403
|
+
id: row.id,
|
|
404
|
+
isHeld: row.isDisabled === true || isCurrentRow(shown, row),
|
|
405
|
+
hasPage: isCommand(row) && row.page !== void 0
|
|
406
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#shownRowFor"));
|
|
407
|
+
const shownQueryOf = (model, shown) => __foldkitBrandViewResult((Option.match(shown.maybePage, {
|
|
408
|
+
onNone: () => __foldkitBrandViewResult((model.query), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~12"),
|
|
409
|
+
onSome: ({ state }) => __foldkitBrandViewResult((state.query), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~11")
|
|
410
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#shownQueryOf");
|
|
411
|
+
const shownPageIdOf = (shown) => __foldkitBrandViewResult((Option.map(shown.maybePage, ({ state }) => __foldkitBrandViewResult((state.commandId), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~33"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#shownPageIdOf");
|
|
412
|
+
const renderedListOf = (model, shown) => (__foldkitBrandViewResult(({
|
|
413
|
+
rows: Array.map(shown.rows, (row) => __foldkitBrandViewResult((shownRowFor(shown, row)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~34")),
|
|
414
|
+
maybeShownCursor: shown.maybeCursorId,
|
|
415
|
+
maybeShownPage: shownPageIdOf(shown),
|
|
416
|
+
shownQuery: shownQueryOf(model, shown),
|
|
417
|
+
shownShift: model.cursorShift
|
|
418
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#renderedListOf"));
|
|
419
|
+
const rowKeysWithRenderedList = (model, shown) => __foldkitBrandViewResult(((key, modifiers) => {
|
|
420
|
+
const snapshot = renderedListOf(model, shown);
|
|
421
|
+
return __foldkitBrandViewResult((isPicking(model) || !isPlain(modifiers) ? Option.none() : Match.value(key).pipe(Match.withReturnType(), Match.whenOr("ArrowDown", "ArrowUp", (arrow) => __foldkitBrandViewResult((Option.some(Message.PressedArrowKey({
|
|
422
|
+
key: arrow,
|
|
423
|
+
snapshot
|
|
424
|
+
}))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~36")), Match.when("Enter", () => __foldkitBrandViewResult((Option.some(Message.PressedEnter({ snapshot }))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~37")), Match.orElse(() => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~38")))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~35");
|
|
425
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#rowKeysWithRenderedList");
|
|
426
|
+
const optionId = (paletteId, index) => __foldkitBrandViewResult((`${paletteId}-option-${index}`), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#optionId");
|
|
427
|
+
const NOTHING_FOUND = "nothing matches · try fewer letters";
|
|
428
|
+
const COMMANDS_FOOT = "↑ ↓ move · enter runs · esc closes";
|
|
429
|
+
const PAGE_FOOT = "↑ ↓ move · enter picks · ⌫ back · esc closes";
|
|
430
|
+
const resultWord = (count) => __foldkitBrandViewResult((count === 1 ? "result" : "results"), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#resultWord");
|
|
431
|
+
const countWords = (count) => __foldkitBrandViewResult((count === 0 ? "Nothing matches." : `${count.toLocaleString(LOCALE)} ${resultWord(count)}.`), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#countWords");
|
|
432
|
+
const rowPartsView = (model, shown, row, h) => {
|
|
433
|
+
const hint = row.isDisabled === true ? row.reason ?? row.hint : row.hint;
|
|
434
|
+
const opens = h.span([h.Class("glyph opens"), h.AriaHidden(true)], [view$1({ name: "caret-right" }, h)]);
|
|
435
|
+
return __foldkitBrandViewResult(([
|
|
436
|
+
...row.glyph === void 0 ? [] : [h.span([h.Class("glyph")], [view$1({ name: row.glyph }, h)])],
|
|
437
|
+
h.span([h.Class("palette-label")], [row.label, ...isContextRow(shown, row) ? [h.span([h.Class("sr-only")], [" (context)"])] : []]),
|
|
438
|
+
...Option.contains(model.maybePicking, row.id) ? [h.span([h.Class("cursor"), h.AriaHidden(true)])] : [],
|
|
439
|
+
...isCurrentRow(shown, row) ? [h.span([h.Class("tag")], ["current"])] : [],
|
|
440
|
+
...hint === void 0 ? [] : [h.span([h.Class("hint")], [hint])],
|
|
441
|
+
...shownRowFor(shown, row).hasPage ? [opens] : []
|
|
442
|
+
]), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#rowPartsView");
|
|
443
|
+
};
|
|
444
|
+
const rowView = (model, shown, row, index, h) => {
|
|
445
|
+
const shownRow = shownRowFor(shown, row);
|
|
446
|
+
return __foldkitBrandViewResult((h.keyed("div")(row.id, [
|
|
447
|
+
h.Id(optionId(id(model), index)),
|
|
448
|
+
h.Role("option"),
|
|
449
|
+
h.AriaSelected(Option.contains(shown.maybeCursorId, row.id)),
|
|
450
|
+
...shownRow.isHeld ? [h.AriaDisabled(true)] : [],
|
|
451
|
+
h.DataAttribute(ROW_ATTRIBUTE, row.id),
|
|
452
|
+
...shownRow.hasPage ? [h.DataAttribute(OPENS_PAGE_ATTRIBUTE, "")] : [],
|
|
453
|
+
h.Class(Array.join([
|
|
454
|
+
"palette-row",
|
|
455
|
+
...row.isAuthored === true ? ["authored"] : [],
|
|
456
|
+
...isContextRow(shown, row) ? ["context"] : []
|
|
457
|
+
], " ")),
|
|
458
|
+
...Option.match(levelOf(row), {
|
|
459
|
+
onNone: () => __foldkitBrandViewResult(([]), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~13"),
|
|
460
|
+
onSome: (level) => __foldkitBrandViewResult(([h.Style({ "--palette-level": `${level}` })]), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~12")
|
|
461
|
+
}),
|
|
462
|
+
...shownRow.isHeld || isPicking(model) ? [] : [h.OnClick(Message.ClickedRow({
|
|
463
|
+
row: shownRow,
|
|
464
|
+
maybeShownPage: shownPageIdOf(shown)
|
|
465
|
+
}))]
|
|
466
|
+
], rowPartsView(model, shown, row, h))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#rowView");
|
|
467
|
+
};
|
|
468
|
+
const groupedRows = (model, shown, h) => {
|
|
469
|
+
const indexed = Array.map(shown.rows, (row, index) => (__foldkitBrandViewResult(({
|
|
470
|
+
row,
|
|
471
|
+
index
|
|
472
|
+
}), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~39")));
|
|
473
|
+
return __foldkitBrandViewResult((Option.match(shown.maybePage, {
|
|
474
|
+
onSome: () => __foldkitBrandViewResult((Array.map(indexed, ({ row, index }) => __foldkitBrandViewResult((rowView(model, shown, row, index, h)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~40"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~13"),
|
|
475
|
+
onNone: () => {
|
|
476
|
+
const groups = Array.dedupe(Array.map(shown.rows, (row) => __foldkitBrandViewResult((isCommand(row) ? row.group : ""), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~41")));
|
|
477
|
+
return __foldkitBrandViewResult((Array.map(groups, (group, groupIndex) => {
|
|
478
|
+
const headingId = `${id(model)}-group-${groupIndex}`;
|
|
479
|
+
return __foldkitBrandViewResult((h.keyed("div")(`group-${group}`, [h.Role("group"), h.AriaLabelledBy(headingId)], [h.div([
|
|
480
|
+
h.Id(headingId),
|
|
481
|
+
h.Role("presentation"),
|
|
482
|
+
h.Class("palette-group")
|
|
483
|
+
], [group]), ...Array.map(Array.filter(indexed, ({ row }) => __foldkitBrandViewResult((isCommand(row) && row.group === group), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~43")), ({ row, index }) => __foldkitBrandViewResult((rowView(model, shown, row, index, h)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~44"))])), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~42");
|
|
484
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~14");
|
|
485
|
+
}
|
|
486
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#groupedRows");
|
|
487
|
+
};
|
|
488
|
+
const comboboxAttributes = (model, shown, noun, h) => {
|
|
489
|
+
const paletteId = id(model);
|
|
490
|
+
const maybeCursorIndex = Option.flatMap(shown.maybeCursorId, (cursorId) => __foldkitBrandViewResult((Array.findFirstIndex(shown.rows, (row) => __foldkitBrandViewResult((row.id === cursorId), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~46"))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~45"));
|
|
491
|
+
return __foldkitBrandViewResult(([
|
|
492
|
+
h.OnKeyDownPreventDefault(rowKeysWithRenderedList(model, shown)),
|
|
493
|
+
h.Role("combobox"),
|
|
494
|
+
h.AriaExpanded(true),
|
|
495
|
+
h.AriaControls(listIdOf(paletteId)),
|
|
496
|
+
h.AriaAutocomplete("list"),
|
|
497
|
+
...Option.toArray(Option.map(maybeCursorIndex, (index) => __foldkitBrandViewResult((h.AriaActiveDescendant(optionId(paletteId, index))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~47"))),
|
|
498
|
+
h.AriaLabel(Option.match(shown.maybePage, {
|
|
499
|
+
onNone: () => __foldkitBrandViewResult((`Command or ${noun}`), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~15"),
|
|
500
|
+
onSome: ({ page }) => __foldkitBrandViewResult((page.title), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~14")
|
|
501
|
+
})),
|
|
502
|
+
h.Autocomplete("off"),
|
|
503
|
+
h.DataAttribute(FIELD_ATTRIBUTE, "")
|
|
504
|
+
]), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#comboboxAttributes");
|
|
505
|
+
};
|
|
506
|
+
const fieldView = (model, shown, noun, render, h) => {
|
|
507
|
+
const maybeShownPage = shownPageIdOf(shown);
|
|
508
|
+
return __foldkitBrandViewResult((Input.view({
|
|
509
|
+
id: fieldId(id(model)),
|
|
510
|
+
value: shownQueryOf(model, shown),
|
|
511
|
+
onInput: (value) => __foldkitBrandViewResult((Message.UpdatedQuery({
|
|
512
|
+
value,
|
|
513
|
+
maybeShownPage
|
|
514
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onInput"),
|
|
515
|
+
isReadOnly: isPicking(model),
|
|
516
|
+
placeholder: Option.match(shown.maybePage, {
|
|
517
|
+
onNone: () => __foldkitBrandViewResult((`type a command or a ${noun}`), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~16"),
|
|
518
|
+
onSome: ({ page }) => __foldkitBrandViewResult((page.find ?? "type to narrow"), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~15")
|
|
519
|
+
}),
|
|
520
|
+
toView: (groups) => __foldkitBrandViewResult((h.input([
|
|
521
|
+
...render.initialFocus,
|
|
522
|
+
...groups.input,
|
|
523
|
+
...comboboxAttributes(model, shown, noun, h)
|
|
524
|
+
])), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#toView")
|
|
525
|
+
}, h)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#fieldView");
|
|
526
|
+
};
|
|
527
|
+
const headView = (model, shown, scope, field, h) => __foldkitBrandViewResult((h.div([h.Class("palette-q field")], [
|
|
528
|
+
...Option.toArray(Option.map(shown.maybePage, () => __foldkitBrandViewResult((view$2({
|
|
529
|
+
glyph: "arrow-left",
|
|
530
|
+
label: "Back",
|
|
531
|
+
isQuiet: true,
|
|
532
|
+
isDisabled: isPicking(model),
|
|
533
|
+
onClick: Message.ClickedBack()
|
|
534
|
+
}, h)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~48"))),
|
|
535
|
+
h.span([h.Class("palette-scope")], [scope]),
|
|
536
|
+
...Option.toArray(Option.map(shown.maybePage, ({ page }) => __foldkitBrandViewResult((h.span([h.Class("palette-title")], [page.title])), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~49"))),
|
|
537
|
+
field
|
|
538
|
+
])), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#headView");
|
|
539
|
+
const listView = (model, shown, h) => __foldkitBrandViewResult((h.div([
|
|
540
|
+
h.Id(listIdOf(id(model))),
|
|
541
|
+
h.Role("listbox"),
|
|
542
|
+
h.AriaLabel(Option.match(shown.maybePage, {
|
|
543
|
+
onNone: () => __foldkitBrandViewResult(("Results"), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~17"),
|
|
544
|
+
onSome: ({ page }) => __foldkitBrandViewResult((page.title), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~16")
|
|
545
|
+
})),
|
|
546
|
+
...isPicking(model) ? [h.AriaBusy(true)] : [],
|
|
547
|
+
h.Class("palette-list")
|
|
548
|
+
], Array.match(shown.rows, {
|
|
549
|
+
onEmpty: () => __foldkitBrandViewResult(([h.div([h.Role("presentation"), h.Class("palette-group")], [NOTHING_FOUND])]), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onEmpty"),
|
|
550
|
+
onNonEmpty: () => __foldkitBrandViewResult((groupedRows(model, shown, h)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNonEmpty")
|
|
551
|
+
}))), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#listView");
|
|
552
|
+
const countView = (model, shown, h) => {
|
|
553
|
+
const shownQuery = shownQueryOf(model, shown);
|
|
554
|
+
return __foldkitBrandViewResult((h.div([h.Role("status"), h.Class("sr-only")], String.isEmpty(shownQuery) ? [] : [countWords(shown.rows.length - HashSet.size(shown.contextIds))])), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#countView");
|
|
555
|
+
};
|
|
556
|
+
const cardView = (model, viewInputs, render, h) => {
|
|
557
|
+
const { commands, scope = "commands", noun = "title", toDetailView = () => __foldkitBrandViewResult(([]), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~50") } = viewInputs;
|
|
558
|
+
const shown = shownOf(model, commands);
|
|
559
|
+
return __foldkitBrandViewResult((h.div([
|
|
560
|
+
...Option.toArray(Option.map(shownPageIdOf(shown), (commandId) => __foldkitBrandViewResult((h.DataAttribute(PAGE_ATTRIBUTE, commandId)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~51"))),
|
|
561
|
+
h.OnMount(BindPaletteKeys()),
|
|
562
|
+
h.Class("card palette")
|
|
563
|
+
], [
|
|
564
|
+
headView(model, shown, scope, fieldView(model, shown, noun, render, h), h),
|
|
565
|
+
...slotView("div", "palette-detail", toDetailView(), h),
|
|
566
|
+
listView(model, shown, h),
|
|
567
|
+
countView(model, shown, h),
|
|
568
|
+
h.div([h.Class("palette-more")], [Option.match(shown.maybePage, {
|
|
569
|
+
onNone: () => __foldkitBrandViewResult((COMMANDS_FOOT), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onNone~18"),
|
|
570
|
+
onSome: () => __foldkitBrandViewResult((PAGE_FOOT), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#onSome~17")
|
|
571
|
+
})])
|
|
572
|
+
])), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#cardView");
|
|
573
|
+
};
|
|
574
|
+
/**
|
|
575
|
+
* Type to find a command or a title; one inverted cursor row, moved by ↑ and ↓ only
|
|
576
|
+
* (stopping at the ends; the pointer shades a row but never moves the cursor); Enter or a
|
|
577
|
+
* click selects it, and the palette closes first so what the command opens takes focus. A
|
|
578
|
+
* command with a page opens that page in place: Back, or Backspace in an empty field, returns
|
|
579
|
+
* to the commands with their query and cursor as they were. The choice in force is tagged
|
|
580
|
+
* current and cannot be picked; a picked choice holds the page until the caller answers. Once
|
|
581
|
+
* a query is typed, a polite status says how many rows it finds. Escape closes the whole
|
|
582
|
+
* palette.
|
|
583
|
+
*
|
|
584
|
+
* A pixel-paper Dialog (named "Commands", hung near the top) holding a field built on
|
|
585
|
+
* `@foldkit/ui`'s Input as an ARIA combobox (`aria-activedescendant` on the cursor's row) over
|
|
586
|
+
* an always open `role="listbox"` of `role="option"` rows, grouped under their headings.
|
|
587
|
+
*/
|
|
588
|
+
const view = defineView((model, viewInputs, h) => __foldkitBrandViewResult((h.submodel({
|
|
589
|
+
slotId: id(model),
|
|
590
|
+
model: model.dialog,
|
|
591
|
+
view: view$3,
|
|
592
|
+
viewInputs: {
|
|
593
|
+
label: "Commands",
|
|
594
|
+
placement: "Top",
|
|
595
|
+
toLiveRegionView: viewInputs.toLiveRegionView,
|
|
596
|
+
toView: (render) => __foldkitBrandViewResult((cardView(model, viewInputs, render, h)), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#toView~2")
|
|
597
|
+
},
|
|
598
|
+
toParentMessage: (message) => __foldkitBrandViewResult((Message.GotDialogMessage({ message })), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#toParentMessage~2")
|
|
599
|
+
})), "@gjermundgaraba/pixel-paper/command-palette/command-palette.js#anonymous~52"));
|
|
600
|
+
export { Model, OutMessage, ReportPendingKeys, ScrollToCursor, id, init, isOpen, isPicking, maybeCursorId, maybePageId, open, openAt, pickFailed, pickSucceeded, query, subscriptions, update, view };
|