@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,449 @@
|
|
|
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, innerControls, isCarrying, measureLift, phaseOf, pressedDraggable, 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 { slotView } from "../slot/slot.js";
|
|
9
|
+
import { prefixKeys } from "../subscription/prefix-keys.js";
|
|
10
|
+
import { Array, Effect, Equal, Match, Option, Schema, pipe } from "effect";
|
|
11
|
+
import * as Command from "foldkit/command";
|
|
12
|
+
import { defineMessageUnion } from "foldkit/message";
|
|
13
|
+
import { Button, DragAndDrop } from "@foldkit/ui";
|
|
14
|
+
import { childAttributes } from "foldkit/html";
|
|
15
|
+
import * as Mount from "foldkit/mount";
|
|
16
|
+
import { modifyFields } from "foldkit/struct";
|
|
17
|
+
import { defineView } from "foldkit/submodel";
|
|
18
|
+
import * as Subscription from "foldkit/subscription";
|
|
19
|
+
import * as Update from "foldkit/update";
|
|
20
|
+
// src/board/board.ts
|
|
21
|
+
/** Schema for one card as the board knows it: its id, unique across the board, and its name
|
|
22
|
+
* in words, which the grip and screen readers use. */
|
|
23
|
+
const Card = Schema.Struct({
|
|
24
|
+
id: Schema.String,
|
|
25
|
+
label: Schema.String
|
|
26
|
+
});
|
|
27
|
+
/** Schema for one column: its id, its title, and its cards in order. */
|
|
28
|
+
const Column = Schema.Struct({
|
|
29
|
+
id: Schema.String,
|
|
30
|
+
title: Schema.String,
|
|
31
|
+
cards: Schema.Array(Card)
|
|
32
|
+
});
|
|
33
|
+
const KEYBOARD_MOVES = "Arrow keys move it to another column, space drops it, escape cancels.";
|
|
34
|
+
const COPY = {
|
|
35
|
+
gripLabel: "Move {card}",
|
|
36
|
+
gripHelp: `Press space to pick the card up. ${KEYBOARD_MOVES}`,
|
|
37
|
+
pickedUp: "Picked up {card}.",
|
|
38
|
+
pickedUpByKeyboard: `Picked up {card}. ${KEYBOARD_MOVES}`,
|
|
39
|
+
over: "{card} is over {column}.",
|
|
40
|
+
dropped: "{card} dropped in {column}.",
|
|
41
|
+
putBack: "{card} put back where it was.",
|
|
42
|
+
cancelled: "Move cancelled. {card} put back where it was."
|
|
43
|
+
};
|
|
44
|
+
const PressPoint = Schema.Struct({
|
|
45
|
+
clientX: Schema.Finite,
|
|
46
|
+
clientY: Schema.Finite
|
|
47
|
+
});
|
|
48
|
+
const Held = Schema.Struct({
|
|
49
|
+
card: Card,
|
|
50
|
+
columnsAtPress: Schema.Array(Column),
|
|
51
|
+
maybePressPoint: Schema.Option(PressPoint)
|
|
52
|
+
});
|
|
53
|
+
/** Schema for a board: the `@foldkit/ui` DragAndDrop it moves cards with, and what it keeps
|
|
54
|
+
* while a card is held. The cards and columns are the parent's. */
|
|
55
|
+
const Model = Schema.Struct({
|
|
56
|
+
dragAndDrop: DragAndDrop.Model,
|
|
57
|
+
maybeHeld: Schema.Option(Held)
|
|
58
|
+
});
|
|
59
|
+
const PressSpot = Schema.Literals(["Body", "Grip"]);
|
|
60
|
+
/** Union of all Messages a board can produce. */
|
|
61
|
+
const Message = defineMessageUnion({
|
|
62
|
+
GotDragAndDropMessage: { message: DragAndDrop.Message },
|
|
63
|
+
PressedCard: {
|
|
64
|
+
cardId: Schema.String,
|
|
65
|
+
spot: PressSpot,
|
|
66
|
+
pointerType: Schema.String,
|
|
67
|
+
screenX: Schema.Finite,
|
|
68
|
+
screenY: Schema.Finite,
|
|
69
|
+
clientX: Schema.Finite,
|
|
70
|
+
clientY: Schema.Finite,
|
|
71
|
+
columnsAtPress: Schema.Array(Column)
|
|
72
|
+
},
|
|
73
|
+
PressedGripKey: {
|
|
74
|
+
cardId: Schema.String,
|
|
75
|
+
columnsAtPress: Schema.Array(Column)
|
|
76
|
+
},
|
|
77
|
+
PressedEscape: {},
|
|
78
|
+
CompletedAnnounceMove: {},
|
|
79
|
+
CompletedSizeLiftedCard: {}
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Union of OutMessages a board reports.
|
|
83
|
+
*
|
|
84
|
+
* - `Moved`: a card was dropped somewhere new. `toIndex` is its place among the destination
|
|
85
|
+
* column's other cards; `maybeAfterCardId` and `maybeBeforeCardId` name the cards it now
|
|
86
|
+
* sits between, the anchors a list that orders by neighbours needs. A drop where the card
|
|
87
|
+
* already was, over no column, or while cards may not move reports nothing. The parent
|
|
88
|
+
* moves the item (or decides not to): the data is its own.
|
|
89
|
+
* - `SelectedCard`: a primary press on a card's body, not on a control inside it (an input,
|
|
90
|
+
* a link, a button other than the title, `[data-no-lift]`) nor its grip.
|
|
91
|
+
*/
|
|
92
|
+
const OutMessage = defineMessageUnion({
|
|
93
|
+
Moved: {
|
|
94
|
+
cardId: Schema.String,
|
|
95
|
+
fromColumnId: Schema.String,
|
|
96
|
+
fromIndex: Schema.Finite,
|
|
97
|
+
toColumnId: Schema.String,
|
|
98
|
+
toIndex: Schema.Finite,
|
|
99
|
+
maybeAfterCardId: Schema.Option(Schema.String),
|
|
100
|
+
maybeBeforeCardId: Schema.Option(Schema.String)
|
|
101
|
+
},
|
|
102
|
+
SelectedCard: { cardId: Schema.String }
|
|
103
|
+
});
|
|
104
|
+
/** Creates a board with nothing held. */
|
|
105
|
+
const init = (config) => (__foldkitBrandViewResult(({
|
|
106
|
+
dragAndDrop: DragAndDrop.init({ id: config.id }),
|
|
107
|
+
maybeHeld: Option.none()
|
|
108
|
+
}), "@gjermundgaraba/pixel-paper/board/board.js#init"));
|
|
109
|
+
/** The board's id, unique in the document. */
|
|
110
|
+
const id = (model) => __foldkitBrandViewResult((model.dragAndDrop.id), "@gjermundgaraba/pixel-paper/board/board.js#id");
|
|
111
|
+
const isDragging = (model) => __foldkitBrandViewResult((DragAndDrop.isDragging(model.dragAndDrop)), "@gjermundgaraba/pixel-paper/board/board.js#isDragging");
|
|
112
|
+
const hookId = (boardId, localId) => __foldkitBrandViewResult((`${boardId}/${localId}`), "@gjermundgaraba/pixel-paper/board/board.js#hookId");
|
|
113
|
+
const cardHook = (model, cardId) => __foldkitBrandViewResult((hookId(id(model), cardId)), "@gjermundgaraba/pixel-paper/board/board.js#cardHook");
|
|
114
|
+
const columnHook = (model, columnId) => __foldkitBrandViewResult((hookId(id(model), columnId)), "@gjermundgaraba/pixel-paper/board/board.js#columnHook");
|
|
115
|
+
const CARD_ATTRIBUTE = "board-card";
|
|
116
|
+
const TITLE_ATTRIBUTE = "board-title";
|
|
117
|
+
const GRIP_ATTRIBUTE = "board-grip";
|
|
118
|
+
/** Says a step of a move through the page's live region (as `Announcer.Announce` does), which is
|
|
119
|
+
* inside the topmost open dialog when there is one. */
|
|
120
|
+
const AnnounceMove = Command.define("AnnounceMove", {
|
|
121
|
+
args: { text: Schema.String },
|
|
122
|
+
messages: [Message.CompletedAnnounceMove],
|
|
123
|
+
execute: ({ text }) => __foldkitBrandViewResult((announce(text).pipe(Effect.as(Message.CompletedAnnounceMove()))), "@gjermundgaraba/pixel-paper/board/board.js#execute")
|
|
124
|
+
});
|
|
125
|
+
const placeOf = (columns, cardId) => __foldkitBrandViewResult((Array.findFirst(columns, (column) => __foldkitBrandViewResult((Array.findFirst(Array.map(column.cards, (card, index) => (__foldkitBrandViewResult(({
|
|
126
|
+
card,
|
|
127
|
+
column,
|
|
128
|
+
index
|
|
129
|
+
}), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~2"))), ({ card }) => __foldkitBrandViewResult((card.id === cardId), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~3"))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous"))), "@gjermundgaraba/pixel-paper/board/board.js#placeOf");
|
|
130
|
+
const fill = (template, card, column = "") => __foldkitBrandViewResult((template.replaceAll("{card}", card).replaceAll("{column}", column)), "@gjermundgaraba/pixel-paper/board/board.js#fill");
|
|
131
|
+
const columnOfHook = (model, held, hook) => __foldkitBrandViewResult((Array.findFirst(held.columnsAtPress, (column) => __foldkitBrandViewResult((columnHook(model, column.id) === hook), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~4"))), "@gjermundgaraba/pixel-paper/board/board.js#columnOfHook");
|
|
132
|
+
const overColumn = (model) => __foldkitBrandViewResult((Option.flatMap(model.maybeHeld, (held) => __foldkitBrandViewResult((Option.flatMap(DragAndDrop.maybeDropTarget(model.dragAndDrop), ({ containerId }) => __foldkitBrandViewResult((columnOfHook(model, held, containerId)), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~6"))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~5"))), "@gjermundgaraba/pixel-paper/board/board.js#overColumn");
|
|
133
|
+
const placementOf = (model, held, toContainerId, rawIndex) => __foldkitBrandViewResult((Option.gen(function* () {
|
|
134
|
+
const from = yield* placeOf(held.columnsAtPress, held.card.id);
|
|
135
|
+
const to = yield* columnOfHook(model, held, toContainerId);
|
|
136
|
+
const others = Array.filter(to.cards, (card) => __foldkitBrandViewResult((card.id !== held.card.id), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~8"));
|
|
137
|
+
const isSameColumn = to.id === from.column.id;
|
|
138
|
+
const isKeyboard = Option.isNone(held.maybePressPoint);
|
|
139
|
+
const pastItself = isSameColumn && rawIndex > from.index ? rawIndex - 1 : rawIndex;
|
|
140
|
+
const toIndex = Math.min(Math.max(pastItself, 0), others.length);
|
|
141
|
+
if (isSameColumn && (isKeyboard || toIndex === from.index)) return __foldkitBrandViewResult((yield* Option.none()), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~7");
|
|
142
|
+
return __foldkitBrandViewResult((OutMessage.Moved({
|
|
143
|
+
cardId: held.card.id,
|
|
144
|
+
fromColumnId: from.column.id,
|
|
145
|
+
fromIndex: from.index,
|
|
146
|
+
toColumnId: to.id,
|
|
147
|
+
toIndex,
|
|
148
|
+
maybeAfterCardId: Option.map(Array.get(others, toIndex - 1), (card) => __foldkitBrandViewResult((card.id), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~9")),
|
|
149
|
+
maybeBeforeCardId: Option.map(Array.get(others, toIndex), (card) => __foldkitBrandViewResult((card.id), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~10"))
|
|
150
|
+
})), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~7");
|
|
151
|
+
})), "@gjermundgaraba/pixel-paper/board/board.js#placementOf");
|
|
152
|
+
const foldDragAndDropOutMessage = DragAndDrop.OutMessage.match({
|
|
153
|
+
Reordered: ({ toContainerId, toIndex }) => __foldkitBrandViewResult(((stepModel) => __foldkitBrandViewResult((Update.withOutMessage({ model: stepModel }, Option.getOrUndefined(Option.flatMap(stepModel.maybeHeld, (held) => __foldkitBrandViewResult((placementOf(stepModel, held, toContainerId, toIndex)), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~12"))))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~11")), "@gjermundgaraba/pixel-paper/board/board.js#Reordered"),
|
|
154
|
+
Cancelled: () => __foldkitBrandViewResult(((stepModel) => (__foldkitBrandViewResult(({ model: stepModel }), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~13"))), "@gjermundgaraba/pixel-paper/board/board.js#Cancelled")
|
|
155
|
+
});
|
|
156
|
+
const toDragAndDropMessage = (message) => __foldkitBrandViewResult((Message.GotDragAndDropMessage({ message })), "@gjermundgaraba/pixel-paper/board/board.js#toDragAndDropMessage");
|
|
157
|
+
const foldDragAndDrop = Update.foldChild({
|
|
158
|
+
update: DragAndDrop.update,
|
|
159
|
+
read: (model) => __foldkitBrandViewResult((Option.some(model.dragAndDrop)), "@gjermundgaraba/pixel-paper/board/board.js#read"),
|
|
160
|
+
write: (model, nextDragAndDrop) => __foldkitBrandViewResult((modifyFields(model, { dragAndDrop: () => __foldkitBrandViewResult((nextDragAndDrop), "@gjermundgaraba/pixel-paper/board/board.js#dragAndDrop") })), "@gjermundgaraba/pixel-paper/board/board.js#write"),
|
|
161
|
+
toParentMessage: toDragAndDropMessage,
|
|
162
|
+
foldOutMessage: foldDragAndDropOutMessage
|
|
163
|
+
});
|
|
164
|
+
const moveText = (held, previous, next, maybeOutMessage, putBack) => {
|
|
165
|
+
const { label } = held.card;
|
|
166
|
+
const before = phaseOf(previous.dragAndDrop);
|
|
167
|
+
const after = phaseOf(next.dragAndDrop);
|
|
168
|
+
const maybeMoved = Option.filter(maybeOutMessage, (outMessage) => __foldkitBrandViewResult((outMessage._tag === "Moved"), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~14"));
|
|
169
|
+
if (after === "Idle") return __foldkitBrandViewResult((isCarrying(before) ? Option.some(Option.match(Option.flatMap(maybeMoved, () => __foldkitBrandViewResult((overColumn(previous)), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~15")), {
|
|
170
|
+
onNone: () => __foldkitBrandViewResult((fill(putBack, label)), "@gjermundgaraba/pixel-paper/board/board.js#onNone"),
|
|
171
|
+
onSome: (column) => __foldkitBrandViewResult((fill(COPY.dropped, label, column.title)), "@gjermundgaraba/pixel-paper/board/board.js#onSome")
|
|
172
|
+
})) : Option.none()), "@gjermundgaraba/pixel-paper/board/board.js#moveText");
|
|
173
|
+
else if (before === "Pressed" && after === "PointerDragging") return __foldkitBrandViewResult((Option.some(fill(COPY.pickedUp, label))), "@gjermundgaraba/pixel-paper/board/board.js#moveText");
|
|
174
|
+
else if (before === "Idle" && after === "KeyboardDragging") return __foldkitBrandViewResult((Option.some(fill(COPY.pickedUpByKeyboard, label))), "@gjermundgaraba/pixel-paper/board/board.js#moveText");
|
|
175
|
+
return __foldkitBrandViewResult((pipe(overColumn(next), Option.filter((column) => __foldkitBrandViewResult((!Equal.equals(Option.map(overColumn(previous), (over) => __foldkitBrandViewResult((over.id), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~17")), Option.some(column.id))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~16")), Option.map((column) => __foldkitBrandViewResult((fill(COPY.over, label, column.title)), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~18")))), "@gjermundgaraba/pixel-paper/board/board.js#moveText");
|
|
176
|
+
};
|
|
177
|
+
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/board/board.js#anonymous~20")), (text) => __foldkitBrandViewResult((AnnounceMove({ text })), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~21")))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~19")), "@gjermundgaraba/pixel-paper/board/board.js#settle");
|
|
178
|
+
const holding = (model, held) => __foldkitBrandViewResult((modifyFields(model, { maybeHeld: () => __foldkitBrandViewResult((Option.some(held)), "@gjermundgaraba/pixel-paper/board/board.js#maybeHeld") })), "@gjermundgaraba/pixel-paper/board/board.js#holding");
|
|
179
|
+
const liftByKeyboard = (model, place, columnsAtPress) => {
|
|
180
|
+
const pressed = holding(model, {
|
|
181
|
+
card: place.card,
|
|
182
|
+
columnsAtPress,
|
|
183
|
+
maybePressPoint: Option.none()
|
|
184
|
+
});
|
|
185
|
+
return __foldkitBrandViewResult((settle(pressed)(foldDragAndDrop(pressed, activatedKeyboardDrag({
|
|
186
|
+
itemId: cardHook(model, place.card.id),
|
|
187
|
+
containerId: columnHook(model, place.column.id),
|
|
188
|
+
index: place.index
|
|
189
|
+
})))), "@gjermundgaraba/pixel-paper/board/board.js#liftByKeyboard");
|
|
190
|
+
};
|
|
191
|
+
const toColumnStepInReadingOrder = (direction) => __foldkitBrandViewResult((Match.value(direction).pipe(Match.withReturnType(), Match.whenOr("Left", "Up", () => __foldkitBrandViewResult(("PreviousContainer"), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~22")), Match.whenOr("Right", "Down", () => __foldkitBrandViewResult(("NextContainer"), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~23")), Match.orElse(() => __foldkitBrandViewResult((direction), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~24")))), "@gjermundgaraba/pixel-paper/board/board.js#toColumnStepInReadingOrder");
|
|
192
|
+
const moveByKeyboard = (model, direction) => __foldkitBrandViewResult((Option.match(Option.filter(Option.all({
|
|
193
|
+
itemId: DragAndDrop.maybeDraggedItemId(model.dragAndDrop),
|
|
194
|
+
target: DragAndDrop.maybeDropTarget(model.dragAndDrop)
|
|
195
|
+
}), () => __foldkitBrandViewResult((phaseOf(model.dragAndDrop) === "KeyboardDragging"), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~25")), {
|
|
196
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/board/board.js#onNone~2")),
|
|
197
|
+
onSome: ({ itemId, target }) => (__foldkitBrandViewResult(({
|
|
198
|
+
model,
|
|
199
|
+
commands: [Command.mapMessage(DragAndDrop.ResolveKeyboardMove({
|
|
200
|
+
itemId,
|
|
201
|
+
currentContainerId: target.containerId,
|
|
202
|
+
currentIndex: target.index,
|
|
203
|
+
direction: toColumnStepInReadingOrder(direction)
|
|
204
|
+
}), toDragAndDropMessage)]
|
|
205
|
+
}), "@gjermundgaraba/pixel-paper/board/board.js#onSome~2"))
|
|
206
|
+
})), "@gjermundgaraba/pixel-paper/board/board.js#moveByKeyboard");
|
|
207
|
+
const isOwnColumnHook = (model, hook) => __foldkitBrandViewResult((Option.exists(model.maybeHeld, (held) => __foldkitBrandViewResult((Option.isSome(columnOfHook(model, held, hook))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~26"))), "@gjermundgaraba/pixel-paper/board/board.js#isOwnColumnHook");
|
|
208
|
+
const cancelDrag = (model, message) => __foldkitBrandViewResult((settle(model, COPY.cancelled)(foldDragAndDrop(model, message))), "@gjermundgaraba/pixel-paper/board/board.js#cancelDrag");
|
|
209
|
+
const updateDragAndDrop = (model, message) => __foldkitBrandViewResult((Match.value(message).pipe(Match.withReturnType(), Match.tag("PressedArrowKey", ({ direction }) => __foldkitBrandViewResult((moveByKeyboard(model, direction)), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~27")), Match.tag("CompletedResolveKeyboardMove", ({ targetContainerId }) => __foldkitBrandViewResult((isOwnColumnHook(model, targetContainerId) ? settle(model)(foldDragAndDrop(model, message)) : { model }), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~28")), Match.tag("CancelledDrag", () => __foldkitBrandViewResult((cancelDrag(model, message)), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~29")), Match.orElse(() => __foldkitBrandViewResult((settle(model)(foldDragAndDrop(model, message))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~30")))), "@gjermundgaraba/pixel-paper/board/board.js#updateDragAndDrop");
|
|
210
|
+
const pressCard = (model) => __foldkitBrandViewResult((({ cardId, spot, pointerType, screenX, screenY, clientX, clientY, columnsAtPress }) => {
|
|
211
|
+
const maybeSelected = Option.liftPredicate(OutMessage.SelectedCard({ cardId }), () => __foldkitBrandViewResult((spot === "Body" && phaseOf(model.dragAndDrop) === "Idle"), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~32"));
|
|
212
|
+
const isLifting = canLift(model) && (spot === "Grip" || pointerType === "mouse");
|
|
213
|
+
const press = Option.match(Option.filter(placeOf(columnsAtPress, cardId), () => __foldkitBrandViewResult((isLifting), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~33")), {
|
|
214
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/board/board.js#onNone~3")),
|
|
215
|
+
onSome: (place) => {
|
|
216
|
+
const pressed = holding(model, {
|
|
217
|
+
card: place.card,
|
|
218
|
+
columnsAtPress,
|
|
219
|
+
maybePressPoint: Option.some({
|
|
220
|
+
clientX,
|
|
221
|
+
clientY
|
|
222
|
+
})
|
|
223
|
+
});
|
|
224
|
+
return __foldkitBrandViewResult((settle(pressed)(foldDragAndDrop(pressed, pressedDraggable({
|
|
225
|
+
itemId: cardHook(model, cardId),
|
|
226
|
+
containerId: columnHook(model, place.column.id),
|
|
227
|
+
index: place.index,
|
|
228
|
+
screenX,
|
|
229
|
+
screenY
|
|
230
|
+
})))), "@gjermundgaraba/pixel-paper/board/board.js#onSome~3");
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
return __foldkitBrandViewResult((Option.match(maybeSelected, {
|
|
234
|
+
onNone: () => __foldkitBrandViewResult((press), "@gjermundgaraba/pixel-paper/board/board.js#onNone~4"),
|
|
235
|
+
onSome: (selected) => (__foldkitBrandViewResult(({
|
|
236
|
+
...press,
|
|
237
|
+
outMessage: selected
|
|
238
|
+
}), "@gjermundgaraba/pixel-paper/board/board.js#onSome~4"))
|
|
239
|
+
})), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~31");
|
|
240
|
+
}), "@gjermundgaraba/pixel-paper/board/board.js#pressCard");
|
|
241
|
+
/**
|
|
242
|
+
* Puts a pressed or held card back where it was, says so, and reports no move. A keyboard
|
|
243
|
+
* move hands focus back to the card's grip. Call it when the layout changes under the board.
|
|
244
|
+
*/
|
|
245
|
+
const cancel = (model) => __foldkitBrandViewResult((cancelDrag(model, cancelledDrag())), "@gjermundgaraba/pixel-paper/board/board.js#cancel");
|
|
246
|
+
/** Processes a board Message and returns the next Model, Commands and OutMessage. */
|
|
247
|
+
const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
248
|
+
GotDragAndDropMessage: ({ message: dragAndDropMessage }) => __foldkitBrandViewResult((updateDragAndDrop(model, dragAndDropMessage)), "@gjermundgaraba/pixel-paper/board/board.js#GotDragAndDropMessage"),
|
|
249
|
+
PressedCard: pressCard(model),
|
|
250
|
+
PressedGripKey: ({ cardId, columnsAtPress }) => __foldkitBrandViewResult((Option.match(Option.filter(placeOf(columnsAtPress, cardId), () => __foldkitBrandViewResult((canLift(model)), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~34")), {
|
|
251
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/board/board.js#onNone~5")),
|
|
252
|
+
onSome: (place) => __foldkitBrandViewResult((liftByKeyboard(model, place, columnsAtPress)), "@gjermundgaraba/pixel-paper/board/board.js#onSome~5")
|
|
253
|
+
})), "@gjermundgaraba/pixel-paper/board/board.js#PressedGripKey"),
|
|
254
|
+
PressedEscape: () => __foldkitBrandViewResult((cancel(model)), "@gjermundgaraba/pixel-paper/board/board.js#PressedEscape"),
|
|
255
|
+
CompletedAnnounceMove: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/board/board.js#CompletedAnnounceMove")),
|
|
256
|
+
CompletedSizeLiftedCard: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/board/board.js#CompletedSizeLiftedCard"))
|
|
257
|
+
})), "@gjermundgaraba/pixel-paper/board/board.js#update");
|
|
258
|
+
const dragSubscriptions = Subscription.lift({
|
|
259
|
+
pointer: DragAndDrop.subscriptions.documentPointer,
|
|
260
|
+
keyboard: DragAndDrop.subscriptions.documentKeyboard,
|
|
261
|
+
autoScroll: DragAndDrop.subscriptions.autoScroll
|
|
262
|
+
})({
|
|
263
|
+
read: (model) => __foldkitBrandViewResult((Option.some(model.dragAndDrop)), "@gjermundgaraba/pixel-paper/board/board.js#read~2"),
|
|
264
|
+
toParentMessage: toDragAndDropMessage
|
|
265
|
+
});
|
|
266
|
+
const boardSubscriptions = Subscription.aggregate(escapeSubscriptions(Message.PressedEscape()), dragSubscriptions);
|
|
267
|
+
/** A held card follows the pointer, the arrows and Space move and drop it, Escape puts it
|
|
268
|
+
* back and the page scrolls near its edges, all from listeners that run only while a card is
|
|
269
|
+
* pressed or held. Lift them into the application's Subscriptions, once per board, with a
|
|
270
|
+
* key prefix of the parent's that no other record on the page uses:
|
|
271
|
+
* `subscriptions("queueBoard")` is keyed `queueBoardEscape`, `queueBoardPointer`,
|
|
272
|
+
* `queueBoardKeyboard` and `queueBoardAutoScroll`, so two boards (or a board beside another
|
|
273
|
+
* DragAndDrop user) aggregate side by side. */
|
|
274
|
+
const subscriptions = (keyPrefix) => __foldkitBrandViewResult((prefixKeys(keyPrefix, boardSubscriptions)), "@gjermundgaraba/pixel-paper/board/board.js#subscriptions");
|
|
275
|
+
/** Sizes the copy that follows the pointer to the card it lifts, and keeps the pointer where
|
|
276
|
+
* it pressed the card. Measures the card once, when the copy appears. */
|
|
277
|
+
const SizeLiftedCard = Mount.define("SizeLiftedCard", {
|
|
278
|
+
args: {
|
|
279
|
+
cardHook: Schema.String,
|
|
280
|
+
pressX: Schema.Finite,
|
|
281
|
+
pressY: Schema.Finite
|
|
282
|
+
},
|
|
283
|
+
messages: [Message.CompletedSizeLiftedCard],
|
|
284
|
+
execute: ({ element, cardHook: hook, pressX, pressY }) => __foldkitBrandViewResult((Effect.sync(() => {
|
|
285
|
+
measureLift(element, `[data-sortable-id="${CSS.escape(hook)}"]`, pressX, pressY);
|
|
286
|
+
return __foldkitBrandViewResult((Message.CompletedSizeLiftedCard()), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~35");
|
|
287
|
+
})), "@gjermundgaraba/pixel-paper/board/board.js#execute~2")
|
|
288
|
+
});
|
|
289
|
+
const INNER_CONTROL = innerControls(`[data-${TITLE_ATTRIBUTE}], [data-${GRIP_ATTRIBUTE}]`);
|
|
290
|
+
const isInside = (outer, inner) => __foldkitBrandViewResult((inner !== null && outer.contains(inner)), "@gjermundgaraba/pixel-paper/board/board.js#isInside");
|
|
291
|
+
const pressSpotOf = (target) => {
|
|
292
|
+
if (!(target instanceof Element)) return __foldkitBrandViewResult((Option.some("Body")), "@gjermundgaraba/pixel-paper/board/board.js#pressSpotOf");
|
|
293
|
+
const maybeCard = Option.fromNullishOr(target.closest(`[data-${CARD_ATTRIBUTE}]`));
|
|
294
|
+
const isOnControl = Option.exists(maybeCard, (card) => __foldkitBrandViewResult((isInside(card, target.closest(INNER_CONTROL))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~36"));
|
|
295
|
+
const isOnGrip = target.closest(`[data-${GRIP_ATTRIBUTE}]`) !== null;
|
|
296
|
+
if (isOnControl) return __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/board/board.js#pressSpotOf");
|
|
297
|
+
else if (isOnGrip) return __foldkitBrandViewResult((Option.some("Grip")), "@gjermundgaraba/pixel-paper/board/board.js#pressSpotOf");
|
|
298
|
+
return __foldkitBrandViewResult((Option.some("Body")), "@gjermundgaraba/pixel-paper/board/board.js#pressSpotOf");
|
|
299
|
+
};
|
|
300
|
+
const gripHelpId = (model) => __foldkitBrandViewResult((`${id(model)}-grip-help`), "@gjermundgaraba/pixel-paper/board/board.js#gripHelpId");
|
|
301
|
+
const isHeldCard = (model, cardId) => __foldkitBrandViewResult((isDragging(model) && Option.exists(DragAndDrop.maybeDraggedItemId(model.dragAndDrop), (heldHook) => __foldkitBrandViewResult((heldHook === cardHook(model, cardId)), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~37"))), "@gjermundgaraba/pixel-paper/board/board.js#isHeldCard");
|
|
302
|
+
const liftedRender = (h) => (__foldkitBrandViewResult(({
|
|
303
|
+
attributes: childAttributes([h.AriaHidden(true), h.Inert(true)]),
|
|
304
|
+
isMovable: false,
|
|
305
|
+
isHeld: false,
|
|
306
|
+
grip: [h.span([
|
|
307
|
+
h.Class("iconbtn"),
|
|
308
|
+
h.DataAttribute(GRIP_ATTRIBUTE, ""),
|
|
309
|
+
h.AriaHidden(true)
|
|
310
|
+
], [view$1({ name: "grip" }, h)])],
|
|
311
|
+
isLifted: true
|
|
312
|
+
}), "@gjermundgaraba/pixel-paper/board/board.js#liftedRender"));
|
|
313
|
+
const cardRender = (info, place, h) => {
|
|
314
|
+
const { model, columns } = info;
|
|
315
|
+
const { card } = place;
|
|
316
|
+
const isIdleNow = phaseOf(model.dragAndDrop) === "Idle";
|
|
317
|
+
const isHeld = isHeldCard(model, card.id);
|
|
318
|
+
const onPress = h.OnPointerDown((pointerType, button, screenX, screenY, _time, clientX, clientY, _pointerId, target) => __foldkitBrandViewResult((Option.map(Option.filter(pressSpotOf(target), () => __foldkitBrandViewResult((isIdleNow && button === 0), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~39")), (spot) => __foldkitBrandViewResult((Message.PressedCard({
|
|
319
|
+
cardId: card.id,
|
|
320
|
+
spot,
|
|
321
|
+
pointerType,
|
|
322
|
+
screenX,
|
|
323
|
+
screenY,
|
|
324
|
+
clientX,
|
|
325
|
+
clientY,
|
|
326
|
+
columnsAtPress: columns
|
|
327
|
+
})), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~40"))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~38"));
|
|
328
|
+
const onGripKey = h.OnKeyDownPreventDefault((key) => __foldkitBrandViewResult((Option.liftPredicate(Message.PressedGripKey({
|
|
329
|
+
cardId: card.id,
|
|
330
|
+
columnsAtPress: columns
|
|
331
|
+
}), () => __foldkitBrandViewResult((isIdleNow && (key === " " || key === "Enter")), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~42"))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~41"));
|
|
332
|
+
const grip = [view$2({
|
|
333
|
+
glyph: "grip",
|
|
334
|
+
label: fill(COPY.gripLabel, card.label),
|
|
335
|
+
isQuiet: true,
|
|
336
|
+
attributes: [
|
|
337
|
+
h.DataAttribute("draggable-id", cardHook(model, card.id)),
|
|
338
|
+
h.DataAttribute(GRIP_ATTRIBUTE, ""),
|
|
339
|
+
h.AriaRoleDescription("draggable"),
|
|
340
|
+
h.AriaDescribedBy(gripHelpId(model)),
|
|
341
|
+
pressedAttribute(isHeld, h),
|
|
342
|
+
onGripKey
|
|
343
|
+
]
|
|
344
|
+
}, h)];
|
|
345
|
+
return __foldkitBrandViewResult(({
|
|
346
|
+
attributes: childAttributes([h.DataAttribute(CARD_ATTRIBUTE, ""), onPress]),
|
|
347
|
+
isMovable: true,
|
|
348
|
+
isHeld,
|
|
349
|
+
grip,
|
|
350
|
+
isLifted: false
|
|
351
|
+
}), "@gjermundgaraba/pixel-paper/board/board.js#cardRender");
|
|
352
|
+
};
|
|
353
|
+
const cardClass = ({ isMovable: movable, isHeld, isLifted }) => __foldkitBrandViewResult((`board-card${movable ? " movable" : ""}${isHeld ? " drag-dim" : ""}${isLifted ? " lifted" : ""}`), "@gjermundgaraba/pixel-paper/board/board.js#cardClass");
|
|
354
|
+
/**
|
|
355
|
+
* One card on the board, from what the board handed `toCardView`: `article.board-card`, a
|
|
356
|
+
* paper slip on the 3px print shadow, its title a two-line `button.title` (or `span.title`
|
|
357
|
+
* without `onOpen`, or the `editor` while the title is edited) over `div.meta-row`, which
|
|
358
|
+
* ends in the grip. Spread
|
|
359
|
+
* `aria-current="true"` through `attributes` for the board's cursor, which prints inverted.
|
|
360
|
+
*/
|
|
361
|
+
const cardView = (config, h) => {
|
|
362
|
+
const { render, title, onOpen, editor = [], meta = [] } = config;
|
|
363
|
+
const attributes = render.isLifted ? [] : config.attributes ?? [];
|
|
364
|
+
const isEditing = !render.isLifted && Array.isReadonlyArrayNonEmpty(editor);
|
|
365
|
+
const titleView = onOpen === void 0 ? h.span([h.Class("title")], [title]) : Button.view({
|
|
366
|
+
onClick: onOpen,
|
|
367
|
+
toView: (groups) => __foldkitBrandViewResult((h.button([
|
|
368
|
+
...groups.button,
|
|
369
|
+
h.DataAttribute(TITLE_ATTRIBUTE, ""),
|
|
370
|
+
h.Class("title")
|
|
371
|
+
], [title])), "@gjermundgaraba/pixel-paper/board/board.js#toView")
|
|
372
|
+
}, h);
|
|
373
|
+
return __foldkitBrandViewResult((h.article([
|
|
374
|
+
...attributes,
|
|
375
|
+
...render.attributes,
|
|
376
|
+
h.Class(cardClass(render))
|
|
377
|
+
], [...isEditing ? editor : [titleView], ...slotView("div", "meta-row", [...meta, ...render.grip], h)])), "@gjermundgaraba/pixel-paper/board/board.js#cardView");
|
|
378
|
+
};
|
|
379
|
+
const cardItemView = (info, place, h) => __foldkitBrandViewResult((h.keyed("li")(place.card.id, [...DragAndDrop.sortable(cardHook(info.model, place.card.id))], [info.toCardView(place.card, cardRender(info, place, h))])), "@gjermundgaraba/pixel-paper/board/board.js#cardItemView");
|
|
380
|
+
const keyboardSlot = (info, column, h) => {
|
|
381
|
+
const { model } = info;
|
|
382
|
+
const maybeSlot = pipe(Option.all({
|
|
383
|
+
held: model.maybeHeld,
|
|
384
|
+
over: overColumn(model)
|
|
385
|
+
}), Option.filter(({ held, over }) => __foldkitBrandViewResult((phaseOf(model.dragAndDrop) === "KeyboardDragging" && over.id === column.id && !Array.some(column.cards, (card) => __foldkitBrandViewResult((card.id === held.card.id), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~44"))), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~43")));
|
|
386
|
+
return __foldkitBrandViewResult((Array.fromOption(Option.map(maybeSlot, ({ held }) => __foldkitBrandViewResult((h.keyed("li")("board-lift-slot", [h.Class("board-lift-slot"), h.AriaHidden(true)], [info.toCardView(held.card, liftedRender(h))])), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~45")))), "@gjermundgaraba/pixel-paper/board/board.js#keyboardSlot");
|
|
387
|
+
};
|
|
388
|
+
const columnView = (info, column, h) => {
|
|
389
|
+
const { model } = info;
|
|
390
|
+
const headingId = `${id(model)}-${column.id}-title`;
|
|
391
|
+
const items = [...keyboardSlot(info, column, h), ...Array.map(column.cards, (card, index) => __foldkitBrandViewResult((cardItemView(info, {
|
|
392
|
+
card,
|
|
393
|
+
column,
|
|
394
|
+
index
|
|
395
|
+
}, h)), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~46"))];
|
|
396
|
+
const isTarget = isDragging(model) && Equal.equals(Option.map(overColumn(model), ({ id: overId }) => __foldkitBrandViewResult((overId), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~47")), Option.some(column.id));
|
|
397
|
+
return __foldkitBrandViewResult((h.keyed("div")(column.id, [h.DataAttribute("droppable-id", columnHook(model, column.id)), h.Class(isTarget ? "board-col drop-target" : "board-col")], [h.section([h.Class("panel"), h.AriaLabelledBy(headingId)], [h.header([h.Class("panel-tb")], [h.h2([h.Id(headingId)], [column.title]), h.span([h.Class("meta")], [column.cards.length.toLocaleString(LOCALE)])]), ...Array.match(items, {
|
|
398
|
+
onEmpty: () => __foldkitBrandViewResult((info.toEmptyView(column)), "@gjermundgaraba/pixel-paper/board/board.js#onEmpty"),
|
|
399
|
+
onNonEmpty: (cards) => __foldkitBrandViewResult(([h.ul([h.Role("list"), h.Class("board-cards")], cards)]), "@gjermundgaraba/pixel-paper/board/board.js#onNonEmpty")
|
|
400
|
+
})])])), "@gjermundgaraba/pixel-paper/board/board.js#columnView");
|
|
401
|
+
};
|
|
402
|
+
const liftedCopyView = (info, h) => {
|
|
403
|
+
const { model } = info;
|
|
404
|
+
const maybeLifted = Option.all({
|
|
405
|
+
style: DragAndDrop.ghostStyle(model.dragAndDrop),
|
|
406
|
+
held: model.maybeHeld,
|
|
407
|
+
pressPoint: Option.flatMap(model.maybeHeld, (held) => __foldkitBrandViewResult((held.maybePressPoint), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~48"))
|
|
408
|
+
});
|
|
409
|
+
return __foldkitBrandViewResult((Array.fromOption(Option.map(maybeLifted, ({ style, held, pressPoint }) => __foldkitBrandViewResult((h.div([
|
|
410
|
+
h.Class("board-lift"),
|
|
411
|
+
h.Style(style),
|
|
412
|
+
h.AriaHidden(true),
|
|
413
|
+
h.OnMount(SizeLiftedCard({
|
|
414
|
+
cardHook: cardHook(model, held.card.id),
|
|
415
|
+
pressX: pressPoint.clientX,
|
|
416
|
+
pressY: pressPoint.clientY
|
|
417
|
+
}))
|
|
418
|
+
], [info.toCardView(held.card, liftedRender(h))])), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~49")))), "@gjermundgaraba/pixel-paper/board/board.js#liftedCopyView");
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* Columns of printed slips, one panel per column (one column on narrow screens), built on
|
|
422
|
+
* `@foldkit/ui`'s DragAndDrop: `div.board` of `div.board-col`, each a `section.panel` titled
|
|
423
|
+
* by its column and holding `ul.board-cards`. The cards are the parent's; each renders
|
|
424
|
+
* through `toCardView`, usually with `cardView`.
|
|
425
|
+
*
|
|
426
|
+
* A press on a card's body reports `SelectedCard`. While cards may move, a mouse drags a slip
|
|
427
|
+
* (a press that moves under 5px stays a click), and touch and the keyboard take its grip:
|
|
428
|
+
* Space or Enter picks the card up, every arrow jumps it one column in reading order, Space
|
|
429
|
+
* drops it at the top of that column and Escape puts it back. A press on a control inside a
|
|
430
|
+
* card does neither. The held card dims in place, a lifted copy follows the pointer, the
|
|
431
|
+
* receiving column is outlined, and each step is said through the page's live region. A drop
|
|
432
|
+
* reports `Moved`; lift `subscriptions(keyPrefix)` into the application's, or nothing
|
|
433
|
+
* follows the pointer or the keys.
|
|
434
|
+
*/
|
|
435
|
+
const view = defineView((model, viewInputs, h) => {
|
|
436
|
+
const { columns, toCardView, toEmptyView = () => __foldkitBrandViewResult(([]), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~51") } = viewInputs;
|
|
437
|
+
const info = {
|
|
438
|
+
model,
|
|
439
|
+
columns,
|
|
440
|
+
toCardView,
|
|
441
|
+
toEmptyView
|
|
442
|
+
};
|
|
443
|
+
return __foldkitBrandViewResult((h.div([h.Class("board"), h.Style({ "--cols": `${columns.length}` })], [
|
|
444
|
+
...Array.map(columns, (column) => __foldkitBrandViewResult((columnView(info, column, h)), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~52")),
|
|
445
|
+
h.p([h.Id(gripHelpId(model)), h.Class("sr-only")], [COPY.gripHelp]),
|
|
446
|
+
...liftedCopyView(info, h)
|
|
447
|
+
])), "@gjermundgaraba/pixel-paper/board/board.js#anonymous~50");
|
|
448
|
+
});
|
|
449
|
+
export { AnnounceMove, Card, Column, Message, Model, OutMessage, SizeLiftedCard, cancel, cardView, id, init, isDragging, subscriptions, update, view };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AnnounceMove, CardRender, CardViewConfig, Column, InitConfig, Message, Model, OutMessage, ViewInputs, cancel, cardView, id, init, subscriptions, update, view } from "./board.js";
|
|
2
|
+
import { isHolding } from "../drag/drag.js";
|
|
3
|
+
declare namespace index_d_exports {
|
|
4
|
+
export { AnnounceMove, CardRender, CardViewConfig, Column, InitConfig, Message, Model, OutMessage, ViewInputs, cancel, cardView, id, init, isHolding, subscriptions, update, view };
|
|
5
|
+
}
|
|
6
|
+
export { AnnounceMove, type CardRender, type CardViewConfig, Column, type InitConfig, Message, Model, OutMessage, type ViewInputs, cancel, cardView, id, index_d_exports, init, isHolding, subscriptions, update, view };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { isHolding } from "../drag/drag.js";
|
|
4
|
+
import { AnnounceMove, Column, Message, Model, OutMessage, cancel, cardView, id, init, subscriptions, update, view } from "./board.js";
|
|
5
|
+
// src/board/index.ts
|
|
6
|
+
var board_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
AnnounceMove: () => __foldkitBrandViewResult((AnnounceMove), "@gjermundgaraba/pixel-paper/board/index.js#AnnounceMove"),
|
|
8
|
+
Column: () => __foldkitBrandViewResult((Column), "@gjermundgaraba/pixel-paper/board/index.js#Column"),
|
|
9
|
+
Message: () => __foldkitBrandViewResult((Message), "@gjermundgaraba/pixel-paper/board/index.js#Message"),
|
|
10
|
+
Model: () => __foldkitBrandViewResult((Model), "@gjermundgaraba/pixel-paper/board/index.js#Model"),
|
|
11
|
+
OutMessage: () => __foldkitBrandViewResult((OutMessage), "@gjermundgaraba/pixel-paper/board/index.js#OutMessage"),
|
|
12
|
+
cancel: () => __foldkitBrandViewResult((cancel), "@gjermundgaraba/pixel-paper/board/index.js#cancel"),
|
|
13
|
+
cardView: () => __foldkitBrandViewResult((cardView), "@gjermundgaraba/pixel-paper/board/index.js#cardView"),
|
|
14
|
+
id: () => __foldkitBrandViewResult((id), "@gjermundgaraba/pixel-paper/board/index.js#id"),
|
|
15
|
+
init: () => __foldkitBrandViewResult((init), "@gjermundgaraba/pixel-paper/board/index.js#init"),
|
|
16
|
+
isHolding: () => __foldkitBrandViewResult((isHolding), "@gjermundgaraba/pixel-paper/board/index.js#isHolding"),
|
|
17
|
+
subscriptions: () => __foldkitBrandViewResult((subscriptions), "@gjermundgaraba/pixel-paper/board/index.js#subscriptions"),
|
|
18
|
+
update: () => __foldkitBrandViewResult((update), "@gjermundgaraba/pixel-paper/board/index.js#update"),
|
|
19
|
+
view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/board/index.js#view")
|
|
20
|
+
});
|
|
21
|
+
export { AnnounceMove, Column, Message, Model, OutMessage, board_exports, cancel, cardView, id, init, isHolding, subscriptions, update, view };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Attributes } from "../attributes/attributes.js";
|
|
2
|
+
import { GlyphName } from "../glyph/glyphs.js";
|
|
3
|
+
import { KeyPlatform } from "../key-hint/key-label.js";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
import { Attribute, Html, HtmlBuilder } from "foldkit/html";
|
|
6
|
+
import { KeySequence } from "foldkit/dom";
|
|
7
|
+
/** How a button prints. `Primary` is the one committing action. `Danger` is the commit inside a
|
|
8
|
+
* confirm, never at rest: a destructive action is a neutral button that opens a danger
|
|
9
|
+
* `ConfirmDialog`. */
|
|
10
|
+
export declare const Variant: Schema.Literals<readonly ["Default", "Primary", "Danger"]>;
|
|
11
|
+
export type Variant = typeof Variant.Type;
|
|
12
|
+
/** What `Button` and `LinkButton` share: the variant, the size, and the default ring. */
|
|
13
|
+
export type Look = Readonly<{
|
|
14
|
+
variant?: Variant;
|
|
15
|
+
isSmall?: boolean;
|
|
16
|
+
/** The action Enter takes in a card: a double ring instead of the print shadow. */
|
|
17
|
+
isDefault?: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
/** The key that does the same as the button, printed small after its words. */
|
|
20
|
+
export type KeyHintConfig = Readonly<{
|
|
21
|
+
keys: KeySequence;
|
|
22
|
+
platform: KeyPlatform;
|
|
23
|
+
}>;
|
|
24
|
+
/** `aria-pressed` for a toggle button, always present so the button reads as a toggle in
|
|
25
|
+
* both states. Shared by every pressable in the system. */
|
|
26
|
+
export declare const pressedAttribute: <Message>(isPressed: boolean, h: HtmlBuilder<Message>) => Attribute<Message>;
|
|
27
|
+
/** Configuration for rendering a button with `view`. */
|
|
28
|
+
export type ViewConfig<Message> = Look & Readonly<{
|
|
29
|
+
label: string;
|
|
30
|
+
onClick?: Message;
|
|
31
|
+
/** Working: a blinking block cursor prints in the right padding, so the label stays put
|
|
32
|
+
* and the button keeps its width. The button is held and says so (`aria-busy`). */
|
|
33
|
+
isBusy?: boolean;
|
|
34
|
+
/** Unavailable: the button is held. As in `@foldkit/ui`, it stays focusable
|
|
35
|
+
* (`aria-disabled`), so focus never falls to the page and Tab still finds it. */
|
|
36
|
+
isDisabled?: boolean;
|
|
37
|
+
keyHint?: KeyHintConfig;
|
|
38
|
+
/** `submit` makes it its form's submit button while it is not held. */
|
|
39
|
+
type?: "button" | "submit";
|
|
40
|
+
/** Further attributes for the `<button>`, such as an id or a Submodel's attribute group. */
|
|
41
|
+
attributes?: Attributes<Message>;
|
|
42
|
+
glyph?: GlyphName;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* The printed button: pixel caps in a 2px ink box on a 3px print shadow, built on
|
|
46
|
+
* `@foldkit/ui`'s `Button`. It is held while busy or disabled: it prints unavailable
|
|
47
|
+
* (`aria-disabled`), has no click handler, keeps its place in the keyboard, and renders as
|
|
48
|
+
* `type="button"` so a held submit button submits nothing, by click or by Enter on itself.
|
|
49
|
+
* While busy it is `aria-busy` too.
|
|
50
|
+
*
|
|
51
|
+
* Enter in a field can still submit a form that has no live submit button, so the form's
|
|
52
|
+
* own update must ignore a submit while its work is saving (see `Card.formView`).
|
|
53
|
+
*/
|
|
54
|
+
export declare const view: <Message>(config: ViewConfig<Message>, h: HtmlBuilder<Message>) => Html;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { view as view$1 } from "../glyph/glyph.js";
|
|
3
|
+
import { view as view$2 } from "../key-hint/key-hint.js";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
import { Button } from "@foldkit/ui";
|
|
6
|
+
Schema.Literals([
|
|
7
|
+
"Default",
|
|
8
|
+
"Primary",
|
|
9
|
+
"Danger"
|
|
10
|
+
]);
|
|
11
|
+
const VARIANT_CLASS = {
|
|
12
|
+
Default: "btn",
|
|
13
|
+
Primary: "btn primary",
|
|
14
|
+
Danger: "btn danger"
|
|
15
|
+
};
|
|
16
|
+
const lookClassName = ({ variant = "Default", isSmall = false, isDefault = false }) => __foldkitBrandViewResult((`${VARIANT_CLASS[variant]}${isSmall ? " small" : ""}${isDefault ? " default-ring" : ""}`), "@gjermundgaraba/pixel-paper/button/button.js#lookClassName");
|
|
17
|
+
/** `aria-pressed` for a toggle button, always present so the button reads as a toggle in
|
|
18
|
+
* both states. Shared by every pressable in the system. */
|
|
19
|
+
const pressedAttribute = (isPressed, h) => __foldkitBrandViewResult((h.AriaPressed(isPressed ? "true" : "false")), "@gjermundgaraba/pixel-paper/button/button.js#pressedAttribute");
|
|
20
|
+
/**
|
|
21
|
+
* The printed button: pixel caps in a 2px ink box on a 3px print shadow, built on
|
|
22
|
+
* `@foldkit/ui`'s `Button`. It is held while busy or disabled: it prints unavailable
|
|
23
|
+
* (`aria-disabled`), has no click handler, keeps its place in the keyboard, and renders as
|
|
24
|
+
* `type="button"` so a held submit button submits nothing, by click or by Enter on itself.
|
|
25
|
+
* While busy it is `aria-busy` too.
|
|
26
|
+
*
|
|
27
|
+
* Enter in a field can still submit a form that has no live submit button, so the form's
|
|
28
|
+
* own update must ignore a submit while its work is saving (see `Card.formView`).
|
|
29
|
+
*/
|
|
30
|
+
const view = (config, h) => {
|
|
31
|
+
const { label, onClick, isBusy = false, isDisabled = false, type = "button", attributes = [], glyph, keyHint } = config;
|
|
32
|
+
const isHeld = isBusy || isDisabled;
|
|
33
|
+
return __foldkitBrandViewResult((Button.view({
|
|
34
|
+
type: isHeld ? "button" : type,
|
|
35
|
+
isDisabled: isHeld,
|
|
36
|
+
...onClick !== void 0 && { onClick },
|
|
37
|
+
toView: (groups) => __foldkitBrandViewResult((h.button([
|
|
38
|
+
...attributes,
|
|
39
|
+
...groups.button,
|
|
40
|
+
...isBusy ? [h.AriaBusy(true)] : [],
|
|
41
|
+
h.Class(lookClassName(config))
|
|
42
|
+
], [
|
|
43
|
+
...glyph === void 0 ? [] : [view$1({ name: glyph }, h)],
|
|
44
|
+
label,
|
|
45
|
+
...keyHint === void 0 ? [] : [view$2(keyHint, h)],
|
|
46
|
+
...isBusy ? [h.span([h.Class("cursor"), h.AriaHidden(true)])] : []
|
|
47
|
+
])), "@gjermundgaraba/pixel-paper/button/button.js#toView")
|
|
48
|
+
}, h)), "@gjermundgaraba/pixel-paper/button/button.js#view");
|
|
49
|
+
};
|
|
50
|
+
export { lookClassName, pressedAttribute, view };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { pressedAttribute, view } from "./button.js";
|
|
4
|
+
// src/button/index.ts
|
|
5
|
+
var button_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
pressedAttribute: () => __foldkitBrandViewResult((pressedAttribute), "@gjermundgaraba/pixel-paper/button/index.js#pressedAttribute"),
|
|
7
|
+
view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/button/index.js#view")
|
|
8
|
+
});
|
|
9
|
+
export { button_exports, pressedAttribute, view };
|