@gjermundgaraba/pixel-paper 0.0.0-stage → 0.1.0
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,431 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { announce } from "../announcer/announcer.js";
|
|
3
|
+
import { view as view$1 } from "../glyph/glyph.js";
|
|
4
|
+
import { pressedAttribute } from "../button/button.js";
|
|
5
|
+
import { activatedKeyboardDrag, canLift, cancelledDrag, escapeSubscriptions, insertionIndex, isCarrying, markDragging, measureLift, movedPointer, phaseOf, pointerMessages as pointerMessages$1, pressedDraggable, releasedPointer, settle as settle$1 } from "../drag/drag.js";
|
|
6
|
+
import { view as view$2 } from "../icon-button/icon-button.js";
|
|
7
|
+
import { LOCALE } from "../locale/locale.js";
|
|
8
|
+
import { prefixKeys } from "../subscription/prefix-keys.js";
|
|
9
|
+
import { Array, Effect, Match, Option, Schema, Stream, pipe } from "effect";
|
|
10
|
+
import * as Command from "foldkit/command";
|
|
11
|
+
import { defineMessageUnion } from "foldkit/message";
|
|
12
|
+
import { DragAndDrop } from "@foldkit/ui";
|
|
13
|
+
import * as Mount from "foldkit/mount";
|
|
14
|
+
import { modifyFields } from "foldkit/struct";
|
|
15
|
+
import { defineView } from "foldkit/submodel";
|
|
16
|
+
import * as Subscription from "foldkit/subscription";
|
|
17
|
+
import * as Update from "foldkit/update";
|
|
18
|
+
// src/sortable/sortable.ts
|
|
19
|
+
/** Schema for one item as the list knows it: its id, unique in the list, and its name in
|
|
20
|
+
* words, which the grip and screen readers use. */
|
|
21
|
+
const Item = Schema.Struct({
|
|
22
|
+
id: Schema.String,
|
|
23
|
+
label: Schema.String
|
|
24
|
+
});
|
|
25
|
+
const KEYBOARD_MOVES = "Arrow keys move it one place, space drops it, escape cancels.";
|
|
26
|
+
const COPY = {
|
|
27
|
+
gripLabel: "Move {item}",
|
|
28
|
+
gripHelp: `Press space to pick the item up. ${KEYBOARD_MOVES}`,
|
|
29
|
+
pickedUp: "Picked up {item}.",
|
|
30
|
+
pickedUpByKeyboard: `Picked up {item}, {position} of {total}. ${KEYBOARD_MOVES}`,
|
|
31
|
+
over: "{item}, {position} of {total}.",
|
|
32
|
+
dropped: "{item} dropped at {position} of {total}.",
|
|
33
|
+
putBack: "{item} put back where it was.",
|
|
34
|
+
cancelled: "Move cancelled. {item} put back where it was."
|
|
35
|
+
};
|
|
36
|
+
const Press = Schema.Struct({
|
|
37
|
+
pointerId: Schema.Finite,
|
|
38
|
+
clientX: Schema.Finite,
|
|
39
|
+
clientY: Schema.Finite
|
|
40
|
+
});
|
|
41
|
+
const Held = Schema.Struct({
|
|
42
|
+
item: Item,
|
|
43
|
+
items: Schema.Array(Item),
|
|
44
|
+
maybePress: Schema.Option(Press)
|
|
45
|
+
});
|
|
46
|
+
/** Schema for a sortable: the `@foldkit/ui` DragAndDrop it moves items with, and what it keeps
|
|
47
|
+
* while an item is held. The items are the parent's. */
|
|
48
|
+
const Model = Schema.Struct({
|
|
49
|
+
dragAndDrop: DragAndDrop.Model,
|
|
50
|
+
maybeHeld: Schema.Option(Held)
|
|
51
|
+
});
|
|
52
|
+
/** Union of all Messages a sortable can produce. */
|
|
53
|
+
const Message = defineMessageUnion({
|
|
54
|
+
GotDragAndDropMessage: { message: DragAndDrop.Message },
|
|
55
|
+
PressedItem: {
|
|
56
|
+
itemId: Schema.String,
|
|
57
|
+
pointerId: Schema.Finite,
|
|
58
|
+
screenX: Schema.Finite,
|
|
59
|
+
screenY: Schema.Finite,
|
|
60
|
+
clientX: Schema.Finite,
|
|
61
|
+
clientY: Schema.Finite,
|
|
62
|
+
items: Schema.Array(Item)
|
|
63
|
+
},
|
|
64
|
+
PressedGripKey: {
|
|
65
|
+
itemId: Schema.String,
|
|
66
|
+
items: Schema.Array(Item)
|
|
67
|
+
},
|
|
68
|
+
MovedPointer: {
|
|
69
|
+
screenX: Schema.Finite,
|
|
70
|
+
screenY: Schema.Finite,
|
|
71
|
+
clientX: Schema.Finite,
|
|
72
|
+
clientY: Schema.Finite,
|
|
73
|
+
maybeIndex: Schema.Option(Schema.Finite)
|
|
74
|
+
},
|
|
75
|
+
ReleasedPointer: {
|
|
76
|
+
screenX: Schema.Finite,
|
|
77
|
+
screenY: Schema.Finite,
|
|
78
|
+
clientX: Schema.Finite,
|
|
79
|
+
clientY: Schema.Finite,
|
|
80
|
+
maybeIndex: Schema.Option(Schema.Finite)
|
|
81
|
+
},
|
|
82
|
+
CancelledPointer: {},
|
|
83
|
+
PressedEscape: {},
|
|
84
|
+
CompletedAnnounceReorder: {},
|
|
85
|
+
CompletedSizeLiftedItem: {}
|
|
86
|
+
});
|
|
87
|
+
/** Union of OutMessages a sortable reports. `Moved`: an item was dropped somewhere new.
|
|
88
|
+
* `toIndex` is its place in the list once moved; `maybeAfterItemId` and `maybeBeforeItemId`
|
|
89
|
+
* name the items it now sits between, the anchors a list ordered by neighbours needs. A drop
|
|
90
|
+
* where the item already was, outside the list, or while items may not move reports nothing.
|
|
91
|
+
* The parent moves the item (or decides not to): the data is its own. */
|
|
92
|
+
const OutMessage = defineMessageUnion({ Moved: {
|
|
93
|
+
itemId: Schema.String,
|
|
94
|
+
fromIndex: Schema.Finite,
|
|
95
|
+
toIndex: Schema.Finite,
|
|
96
|
+
maybeAfterItemId: Schema.Option(Schema.String),
|
|
97
|
+
maybeBeforeItemId: Schema.Option(Schema.String)
|
|
98
|
+
} });
|
|
99
|
+
/** Creates a sortable with nothing held. */
|
|
100
|
+
const init = (config) => (__foldkitBrandViewResult(({
|
|
101
|
+
dragAndDrop: DragAndDrop.init({ id: config.id }),
|
|
102
|
+
maybeHeld: Option.none()
|
|
103
|
+
}), "@gjermundgaraba/pixel-paper/sortable/sortable.js#init"));
|
|
104
|
+
const id = (model) => __foldkitBrandViewResult((model.dragAndDrop.id), "@gjermundgaraba/pixel-paper/sortable/sortable.js#id");
|
|
105
|
+
const itemHook = (model, itemId) => __foldkitBrandViewResult((`${id(model)}/${itemId}`), "@gjermundgaraba/pixel-paper/sortable/sortable.js#itemHook");
|
|
106
|
+
const GRIP_ATTRIBUTE = "sortable-grip";
|
|
107
|
+
/** Says a step of a move through the page's live region (as `Announcer.Announce` does). */
|
|
108
|
+
const AnnounceReorder = Command.define("AnnounceReorder", {
|
|
109
|
+
args: { text: Schema.String },
|
|
110
|
+
messages: [Message.CompletedAnnounceReorder],
|
|
111
|
+
execute: ({ text }) => __foldkitBrandViewResult((announce(text).pipe(Effect.as(Message.CompletedAnnounceReorder()))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#execute")
|
|
112
|
+
});
|
|
113
|
+
const fill = (template, item, position = 0, total = 0) => __foldkitBrandViewResult((template.replaceAll("{item}", item).replaceAll("{position}", position.toLocaleString(LOCALE)).replaceAll("{total}", total.toLocaleString(LOCALE))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#fill");
|
|
114
|
+
const indexOf = (items, itemId) => __foldkitBrandViewResult((Array.findFirstIndex(items, (item) => __foldkitBrandViewResult((item.id === itemId), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous"))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#indexOf");
|
|
115
|
+
const targetIndex = (model, held) => __foldkitBrandViewResult((Option.map(DragAndDrop.maybeDropTarget(model.dragAndDrop), ({ index }) => __foldkitBrandViewResult((Math.min(Math.max(index, 0), held.items.length - 1)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~2"))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#targetIndex");
|
|
116
|
+
const placementOf = (held, rawIndex) => __foldkitBrandViewResult((Option.gen(function* () {
|
|
117
|
+
const fromIndex = yield* indexOf(held.items, held.item.id);
|
|
118
|
+
const others = Array.filter(held.items, (item) => __foldkitBrandViewResult((item.id !== held.item.id), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~4"));
|
|
119
|
+
const toIndex = Math.min(Math.max(rawIndex, 0), others.length);
|
|
120
|
+
if (toIndex === fromIndex) return __foldkitBrandViewResult((yield* Option.none()), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~3");
|
|
121
|
+
return __foldkitBrandViewResult((OutMessage.Moved({
|
|
122
|
+
itemId: held.item.id,
|
|
123
|
+
fromIndex,
|
|
124
|
+
toIndex,
|
|
125
|
+
maybeAfterItemId: Option.map(Array.get(others, toIndex - 1), (item) => __foldkitBrandViewResult((item.id), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~5")),
|
|
126
|
+
maybeBeforeItemId: Option.map(Array.get(others, toIndex), (item) => __foldkitBrandViewResult((item.id), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~6"))
|
|
127
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~3");
|
|
128
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#placementOf");
|
|
129
|
+
const foldDragAndDropOutMessage = DragAndDrop.OutMessage.match({
|
|
130
|
+
Reordered: ({ toIndex }) => __foldkitBrandViewResult(((stepModel) => __foldkitBrandViewResult((Update.withOutMessage({ model: stepModel }, Option.getOrUndefined(Option.flatMap(stepModel.maybeHeld, (held) => __foldkitBrandViewResult((placementOf(held, toIndex)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~8"))))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~7")), "@gjermundgaraba/pixel-paper/sortable/sortable.js#Reordered"),
|
|
131
|
+
Cancelled: () => __foldkitBrandViewResult(((stepModel) => (__foldkitBrandViewResult(({ model: stepModel }), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~9"))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#Cancelled")
|
|
132
|
+
});
|
|
133
|
+
const toDragAndDropMessage = (message) => __foldkitBrandViewResult((Message.GotDragAndDropMessage({ message })), "@gjermundgaraba/pixel-paper/sortable/sortable.js#toDragAndDropMessage");
|
|
134
|
+
const foldDragAndDrop = Update.foldChild({
|
|
135
|
+
update: DragAndDrop.update,
|
|
136
|
+
read: (model) => __foldkitBrandViewResult((Option.some(model.dragAndDrop)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#read"),
|
|
137
|
+
write: (model, nextDragAndDrop) => __foldkitBrandViewResult((modifyFields(model, { dragAndDrop: () => __foldkitBrandViewResult((nextDragAndDrop), "@gjermundgaraba/pixel-paper/sortable/sortable.js#dragAndDrop") })), "@gjermundgaraba/pixel-paper/sortable/sortable.js#write"),
|
|
138
|
+
toParentMessage: toDragAndDropMessage,
|
|
139
|
+
foldOutMessage: foldDragAndDropOutMessage
|
|
140
|
+
});
|
|
141
|
+
const positionOf = (index) => __foldkitBrandViewResult((index + 1), "@gjermundgaraba/pixel-paper/sortable/sortable.js#positionOf");
|
|
142
|
+
const moveText = (held, previous, next, maybeOutMessage, putBack) => {
|
|
143
|
+
const { label } = held.item;
|
|
144
|
+
const total = held.items.length;
|
|
145
|
+
const before = phaseOf(previous.dragAndDrop);
|
|
146
|
+
const after = phaseOf(next.dragAndDrop);
|
|
147
|
+
if (after === "Idle") return __foldkitBrandViewResult((isCarrying(before) ? Option.some(Option.match(maybeOutMessage, {
|
|
148
|
+
onNone: () => __foldkitBrandViewResult((fill(putBack, label)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onNone"),
|
|
149
|
+
onSome: ({ toIndex }) => __foldkitBrandViewResult((fill(COPY.dropped, label, positionOf(toIndex), total)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onSome")
|
|
150
|
+
})) : Option.none()), "@gjermundgaraba/pixel-paper/sortable/sortable.js#moveText");
|
|
151
|
+
else if (before === "Pressed" && after === "PointerDragging") return __foldkitBrandViewResult((Option.some(fill(COPY.pickedUp, label))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#moveText");
|
|
152
|
+
else if (before === "Idle" && after === "KeyboardDragging") return __foldkitBrandViewResult((Option.map(targetIndex(next, held), (index) => __foldkitBrandViewResult((fill(COPY.pickedUpByKeyboard, label, positionOf(index), total)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~10"))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#moveText");
|
|
153
|
+
else if (after === "KeyboardDragging") return __foldkitBrandViewResult((pipe(targetIndex(next, held), Option.filter((index) => __foldkitBrandViewResult((!Option.contains(targetIndex(previous, held), index)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~11")), Option.map((index) => __foldkitBrandViewResult((fill(COPY.over, label, positionOf(index), total)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~12")))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#moveText");
|
|
154
|
+
return __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/sortable/sortable.js#moveText");
|
|
155
|
+
};
|
|
156
|
+
const settle = (previous, putBack = COPY.putBack) => __foldkitBrandViewResult(((dragAndDropUpdate) => __foldkitBrandViewResult((settle$1(dragAndDropUpdate, Option.map(Option.flatMap(previous.maybeHeld, (held) => __foldkitBrandViewResult((moveText(held, previous, dragAndDropUpdate.model, Option.fromNullishOr(dragAndDropUpdate.outMessage), putBack)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~14")), (text) => __foldkitBrandViewResult((AnnounceReorder({ text })), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~15")))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~13")), "@gjermundgaraba/pixel-paper/sortable/sortable.js#settle");
|
|
157
|
+
const liftable = (model, items, itemId) => __foldkitBrandViewResult((Option.filter(Option.map(Array.findFirstWithIndex(items, (item) => __foldkitBrandViewResult((item.id === itemId), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~16")), ([item, index]) => (__foldkitBrandViewResult(({
|
|
158
|
+
index,
|
|
159
|
+
item
|
|
160
|
+
}), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~17"))), () => __foldkitBrandViewResult((canLift(model)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~18"))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#liftable");
|
|
161
|
+
const lift = (model, held, liftMessage) => {
|
|
162
|
+
const pressed = modifyFields(model, { maybeHeld: () => __foldkitBrandViewResult((Option.some(held)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#maybeHeld") });
|
|
163
|
+
return __foldkitBrandViewResult((settle(pressed)(foldDragAndDrop(pressed, liftMessage))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#lift");
|
|
164
|
+
};
|
|
165
|
+
const pointerMove = (model, pointer) => __foldkitBrandViewResult((movedPointer({
|
|
166
|
+
screenX: pointer.screenX,
|
|
167
|
+
screenY: pointer.screenY,
|
|
168
|
+
clientX: pointer.clientX,
|
|
169
|
+
clientY: pointer.clientY,
|
|
170
|
+
maybeDropTarget: Option.map(pointer.maybeIndex, (index) => (__foldkitBrandViewResult(({
|
|
171
|
+
containerId: id(model),
|
|
172
|
+
index
|
|
173
|
+
}), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~19")))
|
|
174
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#pointerMove");
|
|
175
|
+
const isPointerCarrying = (model) => __foldkitBrandViewResult((phaseOf(model.dragAndDrop) === "PointerDragging"), "@gjermundgaraba/pixel-paper/sortable/sortable.js#isPointerCarrying");
|
|
176
|
+
const rereadPointerAtRelease = (model, pointer) => __foldkitBrandViewResult((foldDragAndDrop(model, pointerMove(model, pointer))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#rereadPointerAtRelease");
|
|
177
|
+
const release = (model, pointer) => {
|
|
178
|
+
if (!isPointerCarrying(model)) return __foldkitBrandViewResult((foldDragAndDrop(model, releasedPointer())), "@gjermundgaraba/pixel-paper/sortable/sortable.js#release");
|
|
179
|
+
const moved = rereadPointerAtRelease(model, pointer);
|
|
180
|
+
const released = foldDragAndDrop(moved.model, releasedPointer());
|
|
181
|
+
return __foldkitBrandViewResult((Update.withOutMessage({
|
|
182
|
+
model: released.model,
|
|
183
|
+
commands: [...moved.commands ?? [], ...released.commands ?? []]
|
|
184
|
+
}, released.outMessage)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#release");
|
|
185
|
+
};
|
|
186
|
+
const cancelDrag = (model) => __foldkitBrandViewResult((settle(model, COPY.cancelled)(foldDragAndDrop(model, cancelledDrag()))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#cancelDrag");
|
|
187
|
+
const updateDragAndDrop = (model, message) => __foldkitBrandViewResult((Match.value(message).pipe(Match.withReturnType(), Match.tag("PressedArrowKey", ({ direction }) => __foldkitBrandViewResult((direction === "NextContainer" || direction === "PreviousContainer" ? { model } : settle(model)(foldDragAndDrop(model, message))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~20")), Match.tag("CancelledDrag", () => __foldkitBrandViewResult((cancelDrag(model)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~21")), Match.orElse(() => __foldkitBrandViewResult((settle(model)(foldDragAndDrop(model, message))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~22")))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#updateDragAndDrop");
|
|
188
|
+
/** Processes a sortable Message and returns the next Model, Commands and OutMessage. */
|
|
189
|
+
const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
190
|
+
GotDragAndDropMessage: ({ message: dragAndDropMessage }) => __foldkitBrandViewResult((updateDragAndDrop(model, dragAndDropMessage)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#GotDragAndDropMessage"),
|
|
191
|
+
PressedItem: ({ itemId, pointerId, screenX, screenY, clientX, clientY, items }) => __foldkitBrandViewResult((Option.match(liftable(model, items, itemId), {
|
|
192
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onNone~2")),
|
|
193
|
+
onSome: ({ index, item }) => __foldkitBrandViewResult((lift(model, {
|
|
194
|
+
item,
|
|
195
|
+
items,
|
|
196
|
+
maybePress: Option.some({
|
|
197
|
+
pointerId,
|
|
198
|
+
clientX,
|
|
199
|
+
clientY
|
|
200
|
+
})
|
|
201
|
+
}, pressedDraggable({
|
|
202
|
+
itemId: itemHook(model, itemId),
|
|
203
|
+
containerId: id(model),
|
|
204
|
+
index,
|
|
205
|
+
screenX,
|
|
206
|
+
screenY
|
|
207
|
+
}))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onSome~2")
|
|
208
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#PressedItem"),
|
|
209
|
+
PressedGripKey: ({ itemId, items }) => __foldkitBrandViewResult((Option.match(liftable(model, items, itemId), {
|
|
210
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onNone~3")),
|
|
211
|
+
onSome: ({ index, item }) => __foldkitBrandViewResult((lift(model, {
|
|
212
|
+
item,
|
|
213
|
+
items,
|
|
214
|
+
maybePress: Option.none()
|
|
215
|
+
}, activatedKeyboardDrag({
|
|
216
|
+
itemId: itemHook(model, itemId),
|
|
217
|
+
containerId: id(model),
|
|
218
|
+
index
|
|
219
|
+
}))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onSome~3")
|
|
220
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#PressedGripKey"),
|
|
221
|
+
MovedPointer: (pointer) => __foldkitBrandViewResult((settle(model)(foldDragAndDrop(model, pointerMove(model, pointer)))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#MovedPointer"),
|
|
222
|
+
ReleasedPointer: (pointer) => __foldkitBrandViewResult((settle(model)(release(model, pointer))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#ReleasedPointer"),
|
|
223
|
+
CancelledPointer: () => __foldkitBrandViewResult((settle(model)(foldDragAndDrop(model, cancelledDrag()))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#CancelledPointer"),
|
|
224
|
+
PressedEscape: () => __foldkitBrandViewResult((cancelDrag(model)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#PressedEscape"),
|
|
225
|
+
CompletedAnnounceReorder: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/sortable/sortable.js#CompletedAnnounceReorder")),
|
|
226
|
+
CompletedSizeLiftedItem: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/sortable/sortable.js#CompletedSizeLiftedItem"))
|
|
227
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#update");
|
|
228
|
+
const pointerIndex = (listId, heldHook, clientX, clientY) => __foldkitBrandViewResult((pipe(Array.findFirst(document.elementsFromPoint(clientX, clientY), (element) => __foldkitBrandViewResult((element instanceof HTMLElement && element.dataset["droppableId"] === listId), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~23")), Option.map((list) => __foldkitBrandViewResult((insertionIndex(list, heldHook, clientX, clientY)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~24")))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#pointerIndex");
|
|
229
|
+
const PointerHold = Schema.Struct({
|
|
230
|
+
listId: Schema.String,
|
|
231
|
+
heldHook: Schema.String,
|
|
232
|
+
pointerId: Schema.Finite
|
|
233
|
+
});
|
|
234
|
+
const pointerAt = (hold, event) => (__foldkitBrandViewResult(({
|
|
235
|
+
screenX: event.screenX,
|
|
236
|
+
screenY: event.screenY,
|
|
237
|
+
clientX: event.clientX,
|
|
238
|
+
clientY: event.clientY,
|
|
239
|
+
maybeIndex: pointerIndex(hold.listId, hold.heldHook, event.clientX, event.clientY)
|
|
240
|
+
}), "@gjermundgaraba/pixel-paper/sortable/sortable.js#pointerAt"));
|
|
241
|
+
const pointerMessages = (hold) => __foldkitBrandViewResult((pointerMessages$1(hold.pointerId, {
|
|
242
|
+
moved: (event) => __foldkitBrandViewResult((Message.MovedPointer(pointerAt(hold, event))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#moved"),
|
|
243
|
+
released: (event) => __foldkitBrandViewResult((Message.ReleasedPointer(pointerAt(hold, event))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#released"),
|
|
244
|
+
cancelled: () => __foldkitBrandViewResult((Message.CancelledPointer()), "@gjermundgaraba/pixel-paper/sortable/sortable.js#cancelled")
|
|
245
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#pointerMessages");
|
|
246
|
+
const pointerSubscriptions = Subscription.make()((entry) => (__foldkitBrandViewResult(({ pointer: entry({ maybeHold: Schema.Option(PointerHold) }, {
|
|
247
|
+
modelToDependencies: (model) => (__foldkitBrandViewResult(({ maybeHold: Option.filter(Option.flatMap(model.maybeHeld, ({ item, maybePress }) => __foldkitBrandViewResult((Option.map(maybePress, ({ pointerId }) => (__foldkitBrandViewResult(({
|
|
248
|
+
listId: id(model),
|
|
249
|
+
heldHook: itemHook(model, item.id),
|
|
250
|
+
pointerId
|
|
251
|
+
}), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~27")))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~26")), () => {
|
|
252
|
+
const phase = phaseOf(model.dragAndDrop);
|
|
253
|
+
return __foldkitBrandViewResult((phase === "Pressed" || phase === "PointerDragging"), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~28");
|
|
254
|
+
}) }), "@gjermundgaraba/pixel-paper/sortable/sortable.js#modelToDependencies")),
|
|
255
|
+
dependenciesToStream: ({ maybeHold }) => __foldkitBrandViewResult((Option.match(maybeHold, {
|
|
256
|
+
onNone: () => __foldkitBrandViewResult((Stream.empty), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onNone~4"),
|
|
257
|
+
onSome: (hold) => __foldkitBrandViewResult((Stream.merge(pointerMessages(hold), markDragging)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onSome~4")
|
|
258
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#dependenciesToStream")
|
|
259
|
+
}) }), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~25")));
|
|
260
|
+
const dragSubscriptions = Subscription.lift({
|
|
261
|
+
keyboard: DragAndDrop.subscriptions.documentKeyboard,
|
|
262
|
+
autoScroll: DragAndDrop.subscriptions.autoScroll
|
|
263
|
+
})({
|
|
264
|
+
read: (model) => __foldkitBrandViewResult((Option.some(model.dragAndDrop)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#read~2"),
|
|
265
|
+
toParentMessage: toDragAndDropMessage
|
|
266
|
+
});
|
|
267
|
+
const sortableSubscriptions = Subscription.aggregate(pointerSubscriptions, escapeSubscriptions(Message.PressedEscape()), dragSubscriptions);
|
|
268
|
+
/** A held item follows the pointer, the arrows and Space move and drop it, Escape puts it back
|
|
269
|
+
* and the page scrolls near its edges, from listeners that run only while an item is pressed
|
|
270
|
+
* or held. Lift them into the application's Subscriptions, once per list, behind a key prefix
|
|
271
|
+
* of the parent's: `subscriptions("order")` is keyed `orderPointer`, `orderEscape`,
|
|
272
|
+
* `orderKeyboard` and `orderAutoScroll`. */
|
|
273
|
+
const subscriptions = (keyPrefix) => __foldkitBrandViewResult((prefixKeys(keyPrefix, sortableSubscriptions)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#subscriptions");
|
|
274
|
+
/** Sizes the copy that follows the pointer to the item it lifts, and keeps the pointer where
|
|
275
|
+
* it pressed the item. Measures the item once, when the copy appears. */
|
|
276
|
+
const SizeLiftedItem = Mount.define("SizeLiftedItem", {
|
|
277
|
+
args: {
|
|
278
|
+
itemHook: Schema.String,
|
|
279
|
+
pressX: Schema.Finite,
|
|
280
|
+
pressY: Schema.Finite
|
|
281
|
+
},
|
|
282
|
+
messages: [Message.CompletedSizeLiftedItem],
|
|
283
|
+
execute: ({ element, itemHook: hook, pressX, pressY }) => __foldkitBrandViewResult((Effect.sync(() => {
|
|
284
|
+
measureLift(element, `[data-sortable-id="${CSS.escape(hook)}"]`, pressX, pressY);
|
|
285
|
+
return __foldkitBrandViewResult((Message.CompletedSizeLiftedItem()), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~29");
|
|
286
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#execute~2")
|
|
287
|
+
});
|
|
288
|
+
const helpId = (model) => __foldkitBrandViewResult((`${id(model)}-grip-help`), "@gjermundgaraba/pixel-paper/sortable/sortable.js#helpId");
|
|
289
|
+
const isHeldItem = (model, itemId) => __foldkitBrandViewResult((DragAndDrop.isDragging(model.dragAndDrop) && Option.contains(DragAndDrop.maybeDraggedItemId(model.dragAndDrop), itemHook(model, itemId))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#isHeldItem");
|
|
290
|
+
const liftedGrip = (h) => __foldkitBrandViewResult((h.span([h.Class("iconbtn quiet"), h.AriaHidden(true)], [view$1({ name: "grip" }, h)])), "@gjermundgaraba/pixel-paper/sortable/sortable.js#liftedGrip");
|
|
291
|
+
const itemContents = (info, item, render, h) => {
|
|
292
|
+
const body = h.div([h.Class("sortable-body")], info.toItemView(item, render));
|
|
293
|
+
return __foldkitBrandViewResult((info.layout === "Panels" ? [body] : [render.grip, body]), "@gjermundgaraba/pixel-paper/sortable/sortable.js#itemContents");
|
|
294
|
+
};
|
|
295
|
+
const liftedView = (info, item, h) => __foldkitBrandViewResult((h.div([h.Class("sortable-item lifted")], itemContents(info, item, {
|
|
296
|
+
isLifted: true,
|
|
297
|
+
grip: liftedGrip(h)
|
|
298
|
+
}, h))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#liftedView");
|
|
299
|
+
const gripView = (info, item, h) => {
|
|
300
|
+
const { model, isMovable, items } = info;
|
|
301
|
+
const isIdleNow = phaseOf(model.dragAndDrop) === "Idle";
|
|
302
|
+
const onGripKey = h.OnKeyDownPreventDefault((key) => __foldkitBrandViewResult((Option.liftPredicate(Message.PressedGripKey({
|
|
303
|
+
itemId: item.id,
|
|
304
|
+
items
|
|
305
|
+
}), () => __foldkitBrandViewResult((isIdleNow && (key === " " || key === "Enter")), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~31"))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~30"));
|
|
306
|
+
const onGripPress = h.OnPointerDown((_pointerType, button, screenX, screenY, _time, clientX, clientY, pointerId) => __foldkitBrandViewResult((Option.liftPredicate(Message.PressedItem({
|
|
307
|
+
itemId: item.id,
|
|
308
|
+
pointerId,
|
|
309
|
+
screenX,
|
|
310
|
+
screenY,
|
|
311
|
+
clientX,
|
|
312
|
+
clientY,
|
|
313
|
+
items
|
|
314
|
+
}), () => __foldkitBrandViewResult((isIdleNow && button === 0), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~33"))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~32"));
|
|
315
|
+
return __foldkitBrandViewResult((view$2({
|
|
316
|
+
glyph: "grip",
|
|
317
|
+
label: fill(COPY.gripLabel, item.label),
|
|
318
|
+
isQuiet: true,
|
|
319
|
+
isDisabled: !isMovable,
|
|
320
|
+
attributes: [
|
|
321
|
+
h.DataAttribute("draggable-id", itemHook(model, item.id)),
|
|
322
|
+
h.DataAttribute(GRIP_ATTRIBUTE, ""),
|
|
323
|
+
h.AriaRoleDescription("draggable"),
|
|
324
|
+
h.AriaDescribedBy(helpId(model)),
|
|
325
|
+
pressedAttribute(isHeldItem(model, item.id), h),
|
|
326
|
+
...isMovable ? [onGripKey, onGripPress] : []
|
|
327
|
+
]
|
|
328
|
+
}, h)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#gripView");
|
|
329
|
+
};
|
|
330
|
+
const dropMarkOf = (model) => __foldkitBrandViewResult((pipe(model.maybeHeld, Option.filter(() => __foldkitBrandViewResult((phaseOf(model.dragAndDrop) === "PointerDragging"), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~34")), Option.flatMap((held) => __foldkitBrandViewResult((pipe(targetIndex(model, held), Option.filter((index) => __foldkitBrandViewResult((!Option.contains(indexOf(held.items, held.item.id), index)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~36")), Option.flatMap((index) => {
|
|
331
|
+
const others = Array.filter(held.items, (item) => __foldkitBrandViewResult((item.id !== held.item.id), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~38"));
|
|
332
|
+
return __foldkitBrandViewResult((Option.orElse(Option.map(Array.get(others, index), (item) => (__foldkitBrandViewResult(({
|
|
333
|
+
itemId: item.id,
|
|
334
|
+
side: "Before"
|
|
335
|
+
}), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~39"))), () => __foldkitBrandViewResult((Option.map(Array.last(others), (item) => (__foldkitBrandViewResult(({
|
|
336
|
+
itemId: item.id,
|
|
337
|
+
side: "After"
|
|
338
|
+
}), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~41")))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~40"))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~37");
|
|
339
|
+
}))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~35")))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#dropMarkOf");
|
|
340
|
+
const dropClass = (info, item) => __foldkitBrandViewResult((Option.match(Option.filter(info.maybeDropMark, ({ itemId }) => __foldkitBrandViewResult((itemId === item.id), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~42")), {
|
|
341
|
+
onNone: () => __foldkitBrandViewResult((""), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onNone~5"),
|
|
342
|
+
onSome: ({ side }) => __foldkitBrandViewResult((side === "Before" ? " drop-before" : " drop-after"), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onSome~5")
|
|
343
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#dropClass");
|
|
344
|
+
const itemClass = (info, item) => __foldkitBrandViewResult((`sortable-item${info.isMovable ? " movable" : ""}${isHeldItem(info.model, item.id) ? " drag-dim" : ""}${dropClass(info, item)}`), "@gjermundgaraba/pixel-paper/sortable/sortable.js#itemClass");
|
|
345
|
+
const itemView = (info, item, h) => __foldkitBrandViewResult((h.keyed("li")(item.id, [...DragAndDrop.sortable(itemHook(info.model, item.id)), h.Class(itemClass(info, item))], itemContents(info, item, {
|
|
346
|
+
isLifted: false,
|
|
347
|
+
grip: gripView(info, item, h)
|
|
348
|
+
}, h))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#itemView");
|
|
349
|
+
const itemsView = (info, h) => {
|
|
350
|
+
const { model, items } = info;
|
|
351
|
+
const rows = Array.map(items, (item) => (__foldkitBrandViewResult(({
|
|
352
|
+
item,
|
|
353
|
+
html: itemView(info, item, h)
|
|
354
|
+
}), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~43")));
|
|
355
|
+
const maybeSlot = pipe(model.maybeHeld, Option.filter(() => __foldkitBrandViewResult((phaseOf(model.dragAndDrop) === "KeyboardDragging"), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~44")), Option.flatMap((held) => __foldkitBrandViewResult((Option.map(targetIndex(model, held), (index) => (__foldkitBrandViewResult(({
|
|
356
|
+
held,
|
|
357
|
+
index
|
|
358
|
+
}), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~46")))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~45")));
|
|
359
|
+
return __foldkitBrandViewResult((Option.match(maybeSlot, {
|
|
360
|
+
onNone: () => __foldkitBrandViewResult((Array.map(rows, ({ html }) => __foldkitBrandViewResult((html), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~47"))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onNone~6"),
|
|
361
|
+
onSome: ({ held, index }) => {
|
|
362
|
+
const slot = h.keyed("li")("sortable-slot", [
|
|
363
|
+
h.Class("sortable-slot"),
|
|
364
|
+
h.AriaHidden(true),
|
|
365
|
+
h.Inert(true)
|
|
366
|
+
], [liftedView(info, held.item, h)]);
|
|
367
|
+
const others = Array.filter(rows, ({ item }) => __foldkitBrandViewResult((item.id !== held.item.id), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~48"));
|
|
368
|
+
const maybeBefore = Array.get(others, index);
|
|
369
|
+
return __foldkitBrandViewResult((Option.match(maybeBefore, {
|
|
370
|
+
onNone: () => __foldkitBrandViewResult(([...Array.map(rows, ({ html }) => __foldkitBrandViewResult((html), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~49")), slot]), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onNone~7"),
|
|
371
|
+
onSome: (before) => __foldkitBrandViewResult((Array.flatMap(rows, ({ item, html }) => __foldkitBrandViewResult((item.id === before.item.id ? [slot, html] : [html]), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~50"))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onSome~7")
|
|
372
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#onSome~6");
|
|
373
|
+
}
|
|
374
|
+
})), "@gjermundgaraba/pixel-paper/sortable/sortable.js#itemsView");
|
|
375
|
+
};
|
|
376
|
+
const liftedCopyView = (info, h) => {
|
|
377
|
+
const { model } = info;
|
|
378
|
+
const maybeLifted = Option.all({
|
|
379
|
+
style: DragAndDrop.ghostStyle(model.dragAndDrop),
|
|
380
|
+
held: model.maybeHeld,
|
|
381
|
+
press: Option.flatMap(model.maybeHeld, ({ maybePress }) => __foldkitBrandViewResult((maybePress), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~51"))
|
|
382
|
+
});
|
|
383
|
+
return __foldkitBrandViewResult((Array.fromOption(Option.map(maybeLifted, ({ style, held, press }) => __foldkitBrandViewResult((h.div([
|
|
384
|
+
h.Class("sortable-lift"),
|
|
385
|
+
h.Style(style),
|
|
386
|
+
h.AriaHidden(true),
|
|
387
|
+
h.Inert(true),
|
|
388
|
+
h.OnMount(SizeLiftedItem({
|
|
389
|
+
itemHook: itemHook(model, held.item.id),
|
|
390
|
+
pressX: press.clientX,
|
|
391
|
+
pressY: press.clientY
|
|
392
|
+
}))
|
|
393
|
+
], [liftedView(info, held.item, h)])), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~52")))), "@gjermundgaraba/pixel-paper/sortable/sortable.js#liftedCopyView");
|
|
394
|
+
};
|
|
395
|
+
const layoutClass = (layout) => __foldkitBrandViewResult((Match.value(layout).pipe(Match.withReturnType(), Match.when("List", () => __foldkitBrandViewResult(("sortable"), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~53")), Match.when("Grid", () => __foldkitBrandViewResult(("sortable grid"), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~54")), Match.when("Panels", () => __foldkitBrandViewResult(("sortable panels"), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~55")), Match.exhaustive)), "@gjermundgaraba/pixel-paper/sortable/sortable.js#layoutClass");
|
|
396
|
+
/**
|
|
397
|
+
* Items the reader puts in order, as rows, as tiles or as panels, built on `@foldkit/ui`'s
|
|
398
|
+
* DragAndDrop: `div.sortable` holding `ul.sortable-items` (named by `label`) of
|
|
399
|
+
* `li.sortable-item`, each its grip and the parent's content (a panel holds its grip in its
|
|
400
|
+
* title bar). The items are the parent's; a drop reports `Moved`.
|
|
401
|
+
*
|
|
402
|
+
* Only the grip lifts an item, under every pointer, so the item's own text selects and a
|
|
403
|
+
* finger on it scrolls the page; the keyboard takes the grip too: Space or Enter picks the
|
|
404
|
+
* item up, every arrow moves it one place in reading order, Space drops it and Escape puts it back.
|
|
405
|
+
* The held item dims in place; a copy, lifted onto the card shadow, follows the pointer or
|
|
406
|
+
* prints where the keyboard would drop it; each step is said through the page's live region.
|
|
407
|
+
* Lift `subscriptions(keyPrefix)` into the application's, or nothing follows the pointer or
|
|
408
|
+
* the keys.
|
|
409
|
+
*/
|
|
410
|
+
const view = defineView((model, viewInputs, h) => {
|
|
411
|
+
const { items, label, layout = "List", isReadOnly = false, toItemView } = viewInputs;
|
|
412
|
+
const info = {
|
|
413
|
+
model,
|
|
414
|
+
layout,
|
|
415
|
+
isMovable: !isReadOnly,
|
|
416
|
+
items,
|
|
417
|
+
maybeDropMark: dropMarkOf(model),
|
|
418
|
+
toItemView
|
|
419
|
+
};
|
|
420
|
+
return __foldkitBrandViewResult((h.div([h.Class(layoutClass(layout))], [
|
|
421
|
+
h.ul([
|
|
422
|
+
h.DataAttribute("droppable-id", id(model)),
|
|
423
|
+
h.Role("list"),
|
|
424
|
+
h.AriaLabel(label),
|
|
425
|
+
h.Class("sortable-items")
|
|
426
|
+
], itemsView(info, h)),
|
|
427
|
+
h.p([h.Id(helpId(model)), h.Class("sr-only")], [COPY.gripHelp]),
|
|
428
|
+
...liftedCopyView(info, h)
|
|
429
|
+
])), "@gjermundgaraba/pixel-paper/sortable/sortable.js#anonymous~56");
|
|
430
|
+
});
|
|
431
|
+
export { AnnounceReorder, Item, Message, Model, OutMessage, SizeLiftedItem, init, subscriptions, update, view };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { view } from "./stack.js";
|
|
4
|
+
// src/stack/index.ts
|
|
5
|
+
var stack_exports = /* @__PURE__ */ __exportAll({ view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/stack/index.js#view") });
|
|
6
|
+
export { stack_exports, view };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
3
|
+
/** `M`: the parts of one body (14px). `L`: whole surfaces, panel to panel (24px). */
|
|
4
|
+
export declare const Space: Schema.Literals<readonly ["M", "L"]>;
|
|
5
|
+
export type Space = typeof Space.Type;
|
|
6
|
+
/** Configuration for rendering a stack with `view`. */
|
|
7
|
+
export type ViewConfig = Readonly<{
|
|
8
|
+
body: ReadonlyArray<Html | string>;
|
|
9
|
+
/** `M` by default: the gap inside a panel's body. */
|
|
10
|
+
gap?: Space;
|
|
11
|
+
}>;
|
|
12
|
+
/** A column of components a gap apart; each takes the column's width. Space only: no paper,
|
|
13
|
+
* border or shadow. Put buttons and chips in a Group or a Wrap inside it, so they keep their
|
|
14
|
+
* own width. */
|
|
15
|
+
export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { Match, Schema } from "effect";
|
|
3
|
+
Schema.Literals(["M", "L"]);
|
|
4
|
+
const gapClassName = (gap) => __foldkitBrandViewResult((Match.value(gap).pipe(Match.withReturnType(), Match.when("M", () => __foldkitBrandViewResult(("gap-m"), "@gjermundgaraba/pixel-paper/stack/stack.js#anonymous")), Match.when("L", () => __foldkitBrandViewResult(("gap-l"), "@gjermundgaraba/pixel-paper/stack/stack.js#anonymous~2")), Match.exhaustive)), "@gjermundgaraba/pixel-paper/stack/stack.js#gapClassName");
|
|
5
|
+
/** A column of components a gap apart; each takes the column's width. Space only: no paper,
|
|
6
|
+
* border or shadow. Put buttons and chips in a Group or a Wrap inside it, so they keep their
|
|
7
|
+
* own width. */
|
|
8
|
+
const view = (config, h) => {
|
|
9
|
+
const { body, gap = "M" } = config;
|
|
10
|
+
return __foldkitBrandViewResult((h.div([h.Class(`stack ${gapClassName(gap)}`)], body)), "@gjermundgaraba/pixel-paper/stack/stack.js#view");
|
|
11
|
+
};
|
|
12
|
+
export { view };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { view } from "./stage.js";
|
|
4
|
+
// src/stage/index.ts
|
|
5
|
+
var stage_exports = /* @__PURE__ */ __exportAll({ view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/stage/index.js#view") });
|
|
6
|
+
export { stage_exports, view };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
/** Configuration for rendering a stage with `view`. */
|
|
3
|
+
export type ViewConfig = Readonly<{
|
|
4
|
+
/** The canvas, filling the stage. */
|
|
5
|
+
body: ReadonlyArray<Html | string>;
|
|
6
|
+
/** Editing is paused: a Notice that says why (the link dropped, the page is read-only). The
|
|
7
|
+
* veil comes down over the work, which is inert until this is cleared. */
|
|
8
|
+
paused?: ReadonlyArray<Html | string>;
|
|
9
|
+
}>;
|
|
10
|
+
/** The ground itself, from under the top bar to the window's edges, for a canvas: the main
|
|
11
|
+
* landmark (`<main id="main">`). It does not scroll; what is on it pans. While paused, the
|
|
12
|
+
* work is inert and the reason is on the veil, inside a status (`role="status"`) that stays
|
|
13
|
+
* in place while the veil comes and goes, so a screen reader hears it. */
|
|
14
|
+
export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
// src/stage/stage.ts
|
|
3
|
+
/** The ground itself, from under the top bar to the window's edges, for a canvas: the main
|
|
4
|
+
* landmark (`<main id="main">`). It does not scroll; what is on it pans. While paused, the
|
|
5
|
+
* work is inert and the reason is on the veil, inside a status (`role="status"`) that stays
|
|
6
|
+
* in place while the veil comes and goes, so a screen reader hears it. */
|
|
7
|
+
const view = (config, h) => {
|
|
8
|
+
const { body, paused } = config;
|
|
9
|
+
return __foldkitBrandViewResult((h.main([h.Id("main"), h.Class("stage")], [h.div([h.Class("stage-work"), ...paused === void 0 ? [] : [h.Inert(true)]], [h.div([h.Class("stage-canvas")], body)]), h.div([h.Role("status")], paused === void 0 ? [] : [h.div([h.Class("stage-paused")], paused)])])), "@gjermundgaraba/pixel-paper/stage/stage.js#view");
|
|
10
|
+
};
|
|
11
|
+
export { view };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { listView } from "./stat.js";
|
|
4
|
+
// src/stat/index.ts
|
|
5
|
+
var stat_exports = /* @__PURE__ */ __exportAll({ listView: () => __foldkitBrandViewResult((listView), "@gjermundgaraba/pixel-paper/stat/index.js#listView") });
|
|
6
|
+
export { listView, stat_exports };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Option } from "effect";
|
|
2
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
3
|
+
/** One stat in a `listView`. */
|
|
4
|
+
export type StatConfig = Readonly<{
|
|
5
|
+
/** What is counted, in the label register (`"Requests today"`); unique in its row. It wraps
|
|
6
|
+
* when long. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** The figure, printed in English (41,200). `None` when it is not known: a muted dash, and
|
|
9
|
+
* "not known" for screen readers. */
|
|
10
|
+
maybeValue: Option.Option<number>;
|
|
11
|
+
}>;
|
|
12
|
+
/** Configuration for rendering a row of stats with `listView`. */
|
|
13
|
+
export type ListViewConfig = Readonly<{
|
|
14
|
+
stats: readonly StatConfig[];
|
|
15
|
+
}>;
|
|
16
|
+
/** A row of figures in ruled cells, four across (two on a phone), edge to edge in a flush panel that names what they
|
|
17
|
+
* measure. A description list: each stat is a term and its value. */
|
|
18
|
+
export declare const listView: <Message>(config: ListViewConfig, h: HtmlBuilder<Message>) => Html;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { LOCALE } from "../locale/locale.js";
|
|
3
|
+
import { Array, Option } from "effect";
|
|
4
|
+
// src/stat/stat.ts
|
|
5
|
+
const valueView = (config, h) => __foldkitBrandViewResult((Option.match(config.maybeValue, {
|
|
6
|
+
onNone: () => __foldkitBrandViewResult((h.dd([h.Class("stat-value unknown")], [h.span([h.AriaHidden(true)], ["—"]), h.span([h.Class("sr-only")], ["not known"])])), "@gjermundgaraba/pixel-paper/stat/stat.js#onNone"),
|
|
7
|
+
onSome: (value) => __foldkitBrandViewResult((h.dd([h.Class("stat-value")], [value.toLocaleString(LOCALE)])), "@gjermundgaraba/pixel-paper/stat/stat.js#onSome")
|
|
8
|
+
})), "@gjermundgaraba/pixel-paper/stat/stat.js#valueView");
|
|
9
|
+
const statView = (config, h) => __foldkitBrandViewResult((h.keyed("div")(config.label, [h.Class("stat")], [h.dt([h.Class("label")], [config.label]), valueView(config, h)])), "@gjermundgaraba/pixel-paper/stat/stat.js#statView");
|
|
10
|
+
/** A row of figures in ruled cells, four across (two on a phone), edge to edge in a flush panel that names what they
|
|
11
|
+
* measure. A description list: each stat is a term and its value. */
|
|
12
|
+
const listView = (config, h) => __foldkitBrandViewResult((h.dl([h.Class("stats")], Array.map(config.stats, (stat) => __foldkitBrandViewResult((statView(stat, h)), "@gjermundgaraba/pixel-paper/stat/stat.js#anonymous")))), "@gjermundgaraba/pixel-paper/stat/stat.js#listView");
|
|
13
|
+
export { listView };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MeasureHeight, Message } from "../top-bar/bar-height.js";
|
|
2
|
+
import { KeyNote, ViewConfig, view } from "./status-bar.js";
|
|
3
|
+
declare namespace index_d_exports {
|
|
4
|
+
export { KeyNote, MeasureHeight, Message, ViewConfig, view };
|
|
5
|
+
}
|
|
6
|
+
export { type KeyNote, MeasureHeight, Message, type ViewConfig, index_d_exports, view };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { MeasureHeight, Message } from "../top-bar/bar-height.js";
|
|
4
|
+
import { view } from "./status-bar.js";
|
|
5
|
+
// src/status-bar/index.ts
|
|
6
|
+
var status_bar_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
MeasureHeight: () => __foldkitBrandViewResult((MeasureHeight), "@gjermundgaraba/pixel-paper/status-bar/index.js#MeasureHeight"),
|
|
8
|
+
Message: () => __foldkitBrandViewResult((Message), "@gjermundgaraba/pixel-paper/status-bar/index.js#Message"),
|
|
9
|
+
view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/status-bar/index.js#view")
|
|
10
|
+
});
|
|
11
|
+
export { MeasureHeight, Message, status_bar_exports, view };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { KeyPlatform } from "../key-hint/key-label.js";
|
|
2
|
+
import { Message } from "../top-bar/bar-height.js";
|
|
3
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
4
|
+
import { KeySequence } from "foldkit/dom";
|
|
5
|
+
/** A key worth knowing and what it does, as the key help prints it. */
|
|
6
|
+
export type KeyNote = Readonly<{
|
|
7
|
+
keys: KeySequence;
|
|
8
|
+
does: string;
|
|
9
|
+
}>;
|
|
10
|
+
/** Configuration for rendering a status bar with `view`. */
|
|
11
|
+
export type ViewConfig<Message$1> = Readonly<{
|
|
12
|
+
/** The state, at the left: a LinkState, a sync word, a count. */
|
|
13
|
+
body: ReadonlyArray<Html | string>;
|
|
14
|
+
/** Keys worth knowing, at the right, printed and not pressable. Narrow, they wrap under the
|
|
15
|
+
* state. */
|
|
16
|
+
keys?: readonly KeyNote[];
|
|
17
|
+
platform: KeyPlatform;
|
|
18
|
+
/** Lifts the bar's lifecycle Message (`MeasureHeight` started: the page keeps
|
|
19
|
+
* `--statusbar-h` at the bar's height however it wraps, so the page, the rail, a banner and
|
|
20
|
+
* the toasts stop above it) into the parent's Message, which the parent's update takes and
|
|
21
|
+
* changes nothing for. In a Scene, resolve the Mount by name with the lifted Message:
|
|
22
|
+
* `Scene.Mount.resolve({ name: StatusBar.MeasureHeight.name }, toParentMessage(StatusBar.Message.CompletedMeasureHeight()))`. */
|
|
23
|
+
toParentMessage: (message: Message) => Message$1;
|
|
24
|
+
}>;
|
|
25
|
+
/** The quiet line along the bottom of an interface: what state it is in, and the keys to
|
|
26
|
+
* know. One per page, after the rail and the deck and outside `main`, where it is the page's
|
|
27
|
+
* footer (`<footer>`, the contentinfo landmark). Its keys are content, so each `kbd` is read. */
|
|
28
|
+
export declare const view: <Message>(config: ViewConfig<Message>, h: HtmlBuilder<Message>) => Html;
|