@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,196 @@
|
|
|
1
|
+
import { Effect, Option, Schema } from "effect";
|
|
2
|
+
import * as Command from "foldkit/command";
|
|
3
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
4
|
+
import * as Mount from "foldkit/mount";
|
|
5
|
+
import * as Update from "foldkit/update";
|
|
6
|
+
/** Schema for an inline field. `maybeDraft` is none while the field is untouched: it then
|
|
7
|
+
* shows, and follows, the value it replaces. `replaced` is that value as the view had it at
|
|
8
|
+
* the last edit, so a draft that only restores it writes nothing. `maybeError` is why the
|
|
9
|
+
* last save was refused, until the draft changes or the next save goes out.
|
|
10
|
+
* `maybeLastSavedId` is the id of the item the edit saved last. */
|
|
11
|
+
export declare const Model: Schema.Struct<{
|
|
12
|
+
readonly id: Schema.String;
|
|
13
|
+
readonly phase: import("foldkit/schema").TaggedUnion<{
|
|
14
|
+
readonly Editing: {};
|
|
15
|
+
readonly Saving: {
|
|
16
|
+
trigger: Schema.Literals<readonly ["Enter", "Blur"]>;
|
|
17
|
+
};
|
|
18
|
+
readonly LeftWhileSaving: {};
|
|
19
|
+
readonly Ended: {};
|
|
20
|
+
}>;
|
|
21
|
+
readonly maybeDraft: Schema.Option<Schema.String>;
|
|
22
|
+
readonly replaced: Schema.String;
|
|
23
|
+
readonly maybeError: Schema.Option<Schema.String>;
|
|
24
|
+
readonly maybeLastSavedId: Schema.Option<Schema.String>;
|
|
25
|
+
readonly isRepeating: Schema.Boolean;
|
|
26
|
+
}>;
|
|
27
|
+
export type Model = typeof Model.Type;
|
|
28
|
+
/** Union of all Messages an inline field can produce. `UpdatedDraft` carries the draft and the
|
|
29
|
+
* value it replaces, as the view had it. */
|
|
30
|
+
export declare const Message: import("foldkit/message").MessageUnion<{
|
|
31
|
+
readonly UpdatedDraft: {
|
|
32
|
+
value: Schema.String;
|
|
33
|
+
replaced: Schema.String;
|
|
34
|
+
};
|
|
35
|
+
readonly PressedEnter: {};
|
|
36
|
+
readonly PressedEscape: {};
|
|
37
|
+
readonly BlurredField: {};
|
|
38
|
+
readonly CompletedFocusField: {};
|
|
39
|
+
}>;
|
|
40
|
+
export type Message = typeof Message.Type;
|
|
41
|
+
/** Union of OutMessages an inline field reports. `Committed`: save this text (new, non-empty,
|
|
42
|
+
* trimmed); the field holds until the caller reports back with `succeeded` or `failed`.
|
|
43
|
+
* `Ended`: the edit is over, with how it ended and the id of the item it saved last
|
|
44
|
+
* (`maybeLastSavedId`, none when it saved nothing). Move focus on `Enter` and `Escape` only:
|
|
45
|
+
* after `Blur` the reader chose where focus went. */
|
|
46
|
+
export declare const OutMessage: import("foldkit/message").MessageUnion<{
|
|
47
|
+
readonly Committed: {
|
|
48
|
+
text: Schema.String;
|
|
49
|
+
};
|
|
50
|
+
readonly Ended: {
|
|
51
|
+
how: Schema.Literals<readonly ["Enter", "Blur", "Escape"]>;
|
|
52
|
+
maybeLastSavedId: Schema.Option<Schema.String>;
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
55
|
+
export type OutMessage = typeof OutMessage.Type;
|
|
56
|
+
/** Focuses the field once it renders, selecting its text as an edit begins. */
|
|
57
|
+
export declare const FocusField: Command.CommandDefinitionWithArgs<"FocusField", {
|
|
58
|
+
id: Schema.String;
|
|
59
|
+
}, Effect.Effect<{
|
|
60
|
+
readonly _tag: "CompletedFocusField";
|
|
61
|
+
}, never, never>>;
|
|
62
|
+
/** Configuration for starting an inline edit with `init`. The `id` (the input's) must be
|
|
63
|
+
* unique in the document. `isRepeating`: adding several, so a save from Enter empties the
|
|
64
|
+
* field and keeps it open for the next instead of ending. */
|
|
65
|
+
export type InitConfig = Readonly<{
|
|
66
|
+
id: string;
|
|
67
|
+
isRepeating?: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
/** Starts an inline edit, untouched, focusing and selecting the field. Fold it in with
|
|
70
|
+
* `Update.foldChildInit`. */
|
|
71
|
+
export declare const init: (config: InitConfig) => Update.Return<Model, Message>;
|
|
72
|
+
/** Whether the caller's save is out: the field holds until `succeeded` or `failed`. */
|
|
73
|
+
export declare const isSaving: (model: Model) => boolean;
|
|
74
|
+
/** Why the last save was refused, while the field still holds that text: none before a save
|
|
75
|
+
* fails, and again once the draft changes or the next save goes out. */
|
|
76
|
+
export declare const maybeError: (model: Model) => Option.Option<string>;
|
|
77
|
+
type UpdateReturn = Update.ReturnWithOutMessage<Model, Message, OutMessage>;
|
|
78
|
+
/** Processes an inline field Message and returns the next Model, Commands and OutMessage. */
|
|
79
|
+
export declare const update: (model: Model, message: Message) => Readonly<{
|
|
80
|
+
model: {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly phase: {
|
|
83
|
+
readonly _tag: "Editing";
|
|
84
|
+
} | {
|
|
85
|
+
readonly _tag: "Ended";
|
|
86
|
+
} | {
|
|
87
|
+
readonly _tag: "LeftWhileSaving";
|
|
88
|
+
} | {
|
|
89
|
+
readonly _tag: "Saving";
|
|
90
|
+
readonly trigger: "Blur" | "Enter";
|
|
91
|
+
};
|
|
92
|
+
readonly maybeDraft: Option.Option<string>;
|
|
93
|
+
readonly replaced: string;
|
|
94
|
+
readonly maybeError: Option.Option<string>;
|
|
95
|
+
readonly maybeLastSavedId: Option.Option<string>;
|
|
96
|
+
readonly isRepeating: boolean;
|
|
97
|
+
};
|
|
98
|
+
commands?: Update.Commands<{
|
|
99
|
+
readonly _tag: "PressedEscape";
|
|
100
|
+
} | {
|
|
101
|
+
readonly _tag: "CompletedFocusField";
|
|
102
|
+
} | {
|
|
103
|
+
readonly _tag: "BlurredField";
|
|
104
|
+
} | {
|
|
105
|
+
readonly _tag: "PressedEnter";
|
|
106
|
+
} | {
|
|
107
|
+
readonly _tag: "UpdatedDraft";
|
|
108
|
+
readonly value: string;
|
|
109
|
+
readonly replaced: string;
|
|
110
|
+
}, never>;
|
|
111
|
+
outMessage?: {
|
|
112
|
+
readonly _tag: "Committed";
|
|
113
|
+
readonly text: string;
|
|
114
|
+
} | {
|
|
115
|
+
readonly _tag: "Ended";
|
|
116
|
+
readonly how: "Blur" | "Enter" | "Escape";
|
|
117
|
+
readonly maybeLastSavedId: Option.Option<string>;
|
|
118
|
+
};
|
|
119
|
+
}>;
|
|
120
|
+
/** The caller's save went through, giving the saved item's id. A save from Enter in a
|
|
121
|
+
* repeating field empties the field and keeps it open, focused, for the next; any other
|
|
122
|
+
* save ends the edit (as `Blur` if focus left meanwhile). A result for an edit that is no
|
|
123
|
+
* longer saving changes nothing. */
|
|
124
|
+
export declare const succeeded: (model: Model, savedId: string) => UpdateReturn;
|
|
125
|
+
/** The caller's save did not go through: the field stays open with its text for another try.
|
|
126
|
+
* With an `error` (a refusal) it says why through `errorView`; without one (the save's
|
|
127
|
+
* outcome is told elsewhere, such as a lost connection's notice) it only lets go of the
|
|
128
|
+
* text. It reports nothing, so it folds as a plain return. A result for an edit that is no
|
|
129
|
+
* longer saving changes nothing. */
|
|
130
|
+
export declare const failed: (model: Model, error?: string) => Update.Return<Model, Message>;
|
|
131
|
+
/** The field's keys: Enter saves (or ends, with nothing new to save) and Escape discards and
|
|
132
|
+
* ends, while the edit is open. A key an IME is composing, a modified key and a key someone
|
|
133
|
+
* already handled are left alone; a key it takes has its default prevented, so an Escape here
|
|
134
|
+
* never also closes the dialog around the field. Attached by `view`. In a Scene, resolve it
|
|
135
|
+
* with `Message.PressedEscape`. */
|
|
136
|
+
export declare const BindFieldKeys: Mount.MountDefinitionNoArgs<"BindFieldKeys", {
|
|
137
|
+
readonly _tag: "PressedEscape";
|
|
138
|
+
} | {
|
|
139
|
+
readonly _tag: "PressedEnter";
|
|
140
|
+
}>;
|
|
141
|
+
/** Per-render inputs passed to `view` through `h.submodel`'s `viewInputs`. */
|
|
142
|
+
export type ViewInputs = Readonly<{
|
|
143
|
+
/** The text being replaced; `""` when adding. */
|
|
144
|
+
value: string;
|
|
145
|
+
/** Names the field for screen readers (`"Rename Notes"`, `"New item in Operations"`). */
|
|
146
|
+
label: string;
|
|
147
|
+
placeholder?: string;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* Text edited in place: an input that takes exactly the height of what it replaces, built on
|
|
151
|
+
* `@foldkit/ui`'s Input. Enter or leaving the field with new text reports `Committed`; the
|
|
152
|
+
* field then holds (`readonly`, `aria-busy`, still focused) until the caller reports
|
|
153
|
+
* `succeeded` or `failed`. A refused save keeps the text, marks the field `aria-invalid` and
|
|
154
|
+
* points it at `errorView`. Escape discards the draft and ends. The field moves no focus
|
|
155
|
+
* itself: the caller does on `Ended`.
|
|
156
|
+
*/
|
|
157
|
+
export declare const view: import("foldkit/submodel").View<{
|
|
158
|
+
readonly id: string;
|
|
159
|
+
readonly phase: {
|
|
160
|
+
readonly _tag: "Editing";
|
|
161
|
+
} | {
|
|
162
|
+
readonly _tag: "Ended";
|
|
163
|
+
} | {
|
|
164
|
+
readonly _tag: "LeftWhileSaving";
|
|
165
|
+
} | {
|
|
166
|
+
readonly _tag: "Saving";
|
|
167
|
+
readonly trigger: "Blur" | "Enter";
|
|
168
|
+
};
|
|
169
|
+
readonly maybeDraft: Option.Option<string>;
|
|
170
|
+
readonly replaced: string;
|
|
171
|
+
readonly maybeError: Option.Option<string>;
|
|
172
|
+
readonly maybeLastSavedId: Option.Option<string>;
|
|
173
|
+
readonly isRepeating: boolean;
|
|
174
|
+
}, {
|
|
175
|
+
readonly _tag: "PressedEscape";
|
|
176
|
+
} | {
|
|
177
|
+
readonly _tag: "CompletedFocusField";
|
|
178
|
+
} | {
|
|
179
|
+
readonly _tag: "BlurredField";
|
|
180
|
+
} | {
|
|
181
|
+
readonly _tag: "PressedEnter";
|
|
182
|
+
} | {
|
|
183
|
+
readonly _tag: "UpdatedDraft";
|
|
184
|
+
readonly value: string;
|
|
185
|
+
readonly replaced: string;
|
|
186
|
+
}, Readonly<{
|
|
187
|
+
/** The text being replaced; `""` when adding. */
|
|
188
|
+
value: string;
|
|
189
|
+
/** Names the field for screen readers (`"Rename Notes"`, `"New item in Operations"`). */
|
|
190
|
+
label: string;
|
|
191
|
+
placeholder?: string;
|
|
192
|
+
}>>;
|
|
193
|
+
/** Why the last save was refused, as an error Notice with the id the field points at, or
|
|
194
|
+
* nothing. Place it under the field. */
|
|
195
|
+
export declare const errorView: <ParentMessage>(model: Model, h: HtmlBuilder<ParentMessage>) => Html;
|
|
196
|
+
export {};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { view as view$1 } from "../notice/notice.js";
|
|
3
|
+
import { isPlain } from "../keys/keys.js";
|
|
4
|
+
import { Effect, Match, Option, Schema, String, pipe } from "effect";
|
|
5
|
+
import * as Command from "foldkit/command";
|
|
6
|
+
import { defineMessageUnion } from "foldkit/message";
|
|
7
|
+
import { Input } from "@foldkit/ui";
|
|
8
|
+
import * as Mount from "foldkit/mount";
|
|
9
|
+
import { modifyFields } from "foldkit/struct";
|
|
10
|
+
import { defineView } from "foldkit/submodel";
|
|
11
|
+
import * as Dom from "foldkit/dom";
|
|
12
|
+
import { defineTaggedUnion } from "foldkit/schema";
|
|
13
|
+
// src/inline-input/inline-input.ts
|
|
14
|
+
const SaveTrigger = Schema.Literals(["Enter", "Blur"]);
|
|
15
|
+
const InlineEnd = Schema.Literals([
|
|
16
|
+
"Enter",
|
|
17
|
+
"Blur",
|
|
18
|
+
"Escape"
|
|
19
|
+
]);
|
|
20
|
+
const Phase = defineTaggedUnion({
|
|
21
|
+
Editing: {},
|
|
22
|
+
Saving: { trigger: SaveTrigger },
|
|
23
|
+
LeftWhileSaving: {},
|
|
24
|
+
Ended: {}
|
|
25
|
+
});
|
|
26
|
+
/** Schema for an inline field. `maybeDraft` is none while the field is untouched: it then
|
|
27
|
+
* shows, and follows, the value it replaces. `replaced` is that value as the view had it at
|
|
28
|
+
* the last edit, so a draft that only restores it writes nothing. `maybeError` is why the
|
|
29
|
+
* last save was refused, until the draft changes or the next save goes out.
|
|
30
|
+
* `maybeLastSavedId` is the id of the item the edit saved last. */
|
|
31
|
+
const Model = Schema.Struct({
|
|
32
|
+
id: Schema.String,
|
|
33
|
+
phase: Phase,
|
|
34
|
+
maybeDraft: Schema.Option(Schema.String),
|
|
35
|
+
replaced: Schema.String,
|
|
36
|
+
maybeError: Schema.Option(Schema.String),
|
|
37
|
+
maybeLastSavedId: Schema.Option(Schema.String),
|
|
38
|
+
isRepeating: Schema.Boolean
|
|
39
|
+
});
|
|
40
|
+
/** Union of all Messages an inline field can produce. `UpdatedDraft` carries the draft and the
|
|
41
|
+
* value it replaces, as the view had it. */
|
|
42
|
+
const Message = defineMessageUnion({
|
|
43
|
+
UpdatedDraft: {
|
|
44
|
+
value: Schema.String,
|
|
45
|
+
replaced: Schema.String
|
|
46
|
+
},
|
|
47
|
+
PressedEnter: {},
|
|
48
|
+
PressedEscape: {},
|
|
49
|
+
BlurredField: {},
|
|
50
|
+
CompletedFocusField: {}
|
|
51
|
+
});
|
|
52
|
+
/** Union of OutMessages an inline field reports. `Committed`: save this text (new, non-empty,
|
|
53
|
+
* trimmed); the field holds until the caller reports back with `succeeded` or `failed`.
|
|
54
|
+
* `Ended`: the edit is over, with how it ended and the id of the item it saved last
|
|
55
|
+
* (`maybeLastSavedId`, none when it saved nothing). Move focus on `Enter` and `Escape` only:
|
|
56
|
+
* after `Blur` the reader chose where focus went. */
|
|
57
|
+
const OutMessage = defineMessageUnion({
|
|
58
|
+
Committed: { text: Schema.String },
|
|
59
|
+
Ended: {
|
|
60
|
+
how: InlineEnd,
|
|
61
|
+
maybeLastSavedId: Schema.Option(Schema.String)
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
/** Focuses the field once it renders, selecting its text as an edit begins. */
|
|
65
|
+
const FocusField = Command.define("FocusField", {
|
|
66
|
+
args: { id: Schema.String },
|
|
67
|
+
messages: [Message.CompletedFocusField],
|
|
68
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(`#${CSS.escape(id)}`).pipe(Effect.andThen(Effect.sync(() => {
|
|
69
|
+
const field = document.querySelector(`#${CSS.escape(id)}`);
|
|
70
|
+
if (field instanceof HTMLInputElement) field.select();
|
|
71
|
+
})), Effect.ignore, Effect.as(Message.CompletedFocusField()))), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#execute")
|
|
72
|
+
});
|
|
73
|
+
/** Starts an inline edit, untouched, focusing and selecting the field. Fold it in with
|
|
74
|
+
* `Update.foldChildInit`. */
|
|
75
|
+
const init = (config) => (__foldkitBrandViewResult(({
|
|
76
|
+
model: {
|
|
77
|
+
id: config.id,
|
|
78
|
+
phase: Phase.Editing(),
|
|
79
|
+
maybeDraft: Option.none(),
|
|
80
|
+
replaced: "",
|
|
81
|
+
maybeError: Option.none(),
|
|
82
|
+
maybeLastSavedId: Option.none(),
|
|
83
|
+
isRepeating: config.isRepeating ?? false
|
|
84
|
+
},
|
|
85
|
+
commands: [FocusField({ id: config.id })]
|
|
86
|
+
}), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#init"));
|
|
87
|
+
/** Whether the caller's save is out: the field holds until `succeeded` or `failed`. */
|
|
88
|
+
const isSaving = (model) => __foldkitBrandViewResult((Phase.guards.Saving(model.phase) || Phase.guards.LeftWhileSaving(model.phase)), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#isSaving");
|
|
89
|
+
/** Why the last save was refused, while the field still holds that text: none before a save
|
|
90
|
+
* fails, and again once the draft changes or the next save goes out. */
|
|
91
|
+
const maybeError = (model) => __foldkitBrandViewResult((model.maybeError), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#maybeError");
|
|
92
|
+
const errorId = (model) => __foldkitBrandViewResult((Input.descriptionId(model.id)), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#errorId");
|
|
93
|
+
const end = (model, how) => (__foldkitBrandViewResult(({
|
|
94
|
+
model: modifyFields(model, { phase: () => __foldkitBrandViewResult((Phase.Ended()), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#phase") }),
|
|
95
|
+
outMessage: OutMessage.Ended({
|
|
96
|
+
how,
|
|
97
|
+
maybeLastSavedId: model.maybeLastSavedId
|
|
98
|
+
})
|
|
99
|
+
}), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#end"));
|
|
100
|
+
const toWrite = (maybeDraft, value) => __foldkitBrandViewResult((pipe(maybeDraft, Option.map(String.trim), Option.filter((text) => __foldkitBrandViewResult((String.isNonEmpty(text) && text !== value), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#anonymous~2")))), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#toWrite");
|
|
101
|
+
const commit = (model, trigger) => __foldkitBrandViewResult((Option.match(toWrite(model.maybeDraft, model.replaced), {
|
|
102
|
+
onNone: () => __foldkitBrandViewResult((end(model, trigger)), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#onNone"),
|
|
103
|
+
onSome: (text) => (__foldkitBrandViewResult(({
|
|
104
|
+
model: modifyFields(model, {
|
|
105
|
+
phase: () => __foldkitBrandViewResult((Phase.Saving({ trigger })), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#phase~2"),
|
|
106
|
+
maybeError: () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#maybeError~2")
|
|
107
|
+
}),
|
|
108
|
+
outMessage: OutMessage.Committed({ text })
|
|
109
|
+
}), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#onSome"))
|
|
110
|
+
})), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#commit");
|
|
111
|
+
/** Processes an inline field Message and returns the next Model, Commands and OutMessage. */
|
|
112
|
+
const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
113
|
+
UpdatedDraft: ({ value, replaced }) => __foldkitBrandViewResult((Phase.guards.Editing(model.phase) ? { model: modifyFields(model, {
|
|
114
|
+
maybeDraft: () => __foldkitBrandViewResult((Option.some(value)), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#maybeDraft"),
|
|
115
|
+
replaced: () => __foldkitBrandViewResult((replaced), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#replaced"),
|
|
116
|
+
maybeError: () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#maybeError~3")
|
|
117
|
+
}) } : { model }), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#UpdatedDraft"),
|
|
118
|
+
PressedEnter: () => __foldkitBrandViewResult((Phase.guards.Editing(model.phase) ? commit(model, "Enter") : { model }), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#PressedEnter"),
|
|
119
|
+
PressedEscape: () => __foldkitBrandViewResult((Phase.guards.Editing(model.phase) ? end(model, "Escape") : { model }), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#PressedEscape"),
|
|
120
|
+
BlurredField: () => __foldkitBrandViewResult((Phase.match(model.phase, {
|
|
121
|
+
Editing: () => __foldkitBrandViewResult((commit(model, "Blur")), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#Editing"),
|
|
122
|
+
Saving: () => (__foldkitBrandViewResult(({ model: modifyFields(model, { phase: () => __foldkitBrandViewResult((Phase.LeftWhileSaving()), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#phase~3") }) }), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#Saving")),
|
|
123
|
+
LeftWhileSaving: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#LeftWhileSaving")),
|
|
124
|
+
Ended: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#Ended"))
|
|
125
|
+
})), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#BlurredField"),
|
|
126
|
+
CompletedFocusField: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#CompletedFocusField"))
|
|
127
|
+
})), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#update");
|
|
128
|
+
const savedAs = (model, savedId) => __foldkitBrandViewResult((modifyFields(model, { maybeLastSavedId: () => __foldkitBrandViewResult((Option.some(savedId)), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#maybeLastSavedId") })), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#savedAs");
|
|
129
|
+
/** The caller's save went through, giving the saved item's id. A save from Enter in a
|
|
130
|
+
* repeating field empties the field and keeps it open, focused, for the next; any other
|
|
131
|
+
* save ends the edit (as `Blur` if focus left meanwhile). A result for an edit that is no
|
|
132
|
+
* longer saving changes nothing. */
|
|
133
|
+
const succeeded = (model, savedId) => __foldkitBrandViewResult((Phase.match(model.phase, {
|
|
134
|
+
Saving: ({ trigger }) => {
|
|
135
|
+
const saved = savedAs(model, savedId);
|
|
136
|
+
return __foldkitBrandViewResult((model.isRepeating && trigger === "Enter" ? { model: modifyFields(saved, {
|
|
137
|
+
phase: () => __foldkitBrandViewResult((Phase.Editing()), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#phase~4"),
|
|
138
|
+
maybeDraft: () => __foldkitBrandViewResult((Option.some("")), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#maybeDraft~2")
|
|
139
|
+
}) } : end(saved, trigger)), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#Saving~2");
|
|
140
|
+
},
|
|
141
|
+
LeftWhileSaving: () => __foldkitBrandViewResult((end(savedAs(model, savedId), "Blur")), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#LeftWhileSaving~2"),
|
|
142
|
+
Editing: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#Editing~2")),
|
|
143
|
+
Ended: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#Ended~2"))
|
|
144
|
+
})), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#succeeded");
|
|
145
|
+
/** The caller's save did not go through: the field stays open with its text for another try.
|
|
146
|
+
* With an `error` (a refusal) it says why through `errorView`; without one (the save's
|
|
147
|
+
* outcome is told elsewhere, such as a lost connection's notice) it only lets go of the
|
|
148
|
+
* text. It reports nothing, so it folds as a plain return. A result for an edit that is no
|
|
149
|
+
* longer saving changes nothing. */
|
|
150
|
+
const failed = (model, error) => __foldkitBrandViewResult((isSaving(model) ? { model: modifyFields(model, {
|
|
151
|
+
phase: () => __foldkitBrandViewResult((Phase.Editing()), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#phase~5"),
|
|
152
|
+
maybeError: () => __foldkitBrandViewResult((Option.fromNullishOr(error)), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#maybeError~4")
|
|
153
|
+
}) } : { model }), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#failed");
|
|
154
|
+
const fieldKey = (event) => __foldkitBrandViewResult((event.isComposing || event.defaultPrevented || !isPlain(event) ? Option.none() : Match.value(event.key).pipe(Match.withReturnType(), Match.when("Enter", () => __foldkitBrandViewResult((Option.some(Message.PressedEnter())), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#anonymous~3")), Match.when("Escape", () => __foldkitBrandViewResult((Option.some(Message.PressedEscape())), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#anonymous~4")), Match.orElse(() => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#anonymous~5")))), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#fieldKey");
|
|
155
|
+
/** The field's keys: Enter saves (or ends, with nothing new to save) and Escape discards and
|
|
156
|
+
* ends, while the edit is open. A key an IME is composing, a modified key and a key someone
|
|
157
|
+
* already handled are left alone; a key it takes has its default prevented, so an Escape here
|
|
158
|
+
* never also closes the dialog around the field. Attached by `view`. In a Scene, resolve it
|
|
159
|
+
* with `Message.PressedEscape`. */
|
|
160
|
+
const BindFieldKeys = Mount.defineStream("BindFieldKeys", {
|
|
161
|
+
messages: [Message.PressedEnter, Message.PressedEscape],
|
|
162
|
+
execute: ({ element }) => __foldkitBrandViewResult((Dom.streamFromEventFilterMapPreventDefault({
|
|
163
|
+
target: element,
|
|
164
|
+
type: "keydown",
|
|
165
|
+
filterMapEvent: fieldKey
|
|
166
|
+
})), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#execute~2")
|
|
167
|
+
});
|
|
168
|
+
/**
|
|
169
|
+
* Text edited in place: an input that takes exactly the height of what it replaces, built on
|
|
170
|
+
* `@foldkit/ui`'s Input. Enter or leaving the field with new text reports `Committed`; the
|
|
171
|
+
* field then holds (`readonly`, `aria-busy`, still focused) until the caller reports
|
|
172
|
+
* `succeeded` or `failed`. A refused save keeps the text, marks the field `aria-invalid` and
|
|
173
|
+
* points it at `errorView`. Escape discards the draft and ends. The field moves no focus
|
|
174
|
+
* itself: the caller does on `Ended`.
|
|
175
|
+
*/
|
|
176
|
+
const view = defineView((model, viewInputs, h) => {
|
|
177
|
+
const { value, label, placeholder } = viewInputs;
|
|
178
|
+
const isHeld = isSaving(model);
|
|
179
|
+
const hasError = Option.isSome(model.maybeError);
|
|
180
|
+
return __foldkitBrandViewResult((Input.view({
|
|
181
|
+
id: model.id,
|
|
182
|
+
value: Option.getOrElse(model.maybeDraft, () => __foldkitBrandViewResult((value), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#anonymous~7")),
|
|
183
|
+
onInput: (draft) => __foldkitBrandViewResult((Message.UpdatedDraft({
|
|
184
|
+
value: draft,
|
|
185
|
+
replaced: value
|
|
186
|
+
})), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#onInput"),
|
|
187
|
+
isReadOnly: isHeld,
|
|
188
|
+
isInvalid: hasError,
|
|
189
|
+
hasDescription: hasError,
|
|
190
|
+
...placeholder !== void 0 && { placeholder },
|
|
191
|
+
toView: (groups) => __foldkitBrandViewResult((h.input([
|
|
192
|
+
...groups.input,
|
|
193
|
+
h.AriaLabel(label),
|
|
194
|
+
...isHeld ? [h.AriaBusy(true)] : [],
|
|
195
|
+
h.Autocomplete("off"),
|
|
196
|
+
h.OnBlur(Message.BlurredField()),
|
|
197
|
+
h.OnMount(BindFieldKeys()),
|
|
198
|
+
h.Class("inline-input")
|
|
199
|
+
])), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#toView")
|
|
200
|
+
}, h)), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#anonymous~6");
|
|
201
|
+
});
|
|
202
|
+
/** Why the last save was refused, as an error Notice with the id the field points at, or
|
|
203
|
+
* nothing. Place it under the field. */
|
|
204
|
+
const errorView = (model, h) => __foldkitBrandViewResult((Option.match(model.maybeError, {
|
|
205
|
+
onNone: () => __foldkitBrandViewResult((h.empty), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#onNone~2"),
|
|
206
|
+
onSome: (shown) => __foldkitBrandViewResult((view$1({
|
|
207
|
+
tone: "Error",
|
|
208
|
+
body: [shown],
|
|
209
|
+
attributes: [h.Id(errorId(model))]
|
|
210
|
+
}, h)), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#onSome~2")
|
|
211
|
+
})), "@gjermundgaraba/pixel-paper/inline-input/inline-input.js#errorView");
|
|
212
|
+
export { BindFieldKeys, FocusField, Message, Model, OutMessage, errorView, failed, fieldKey, init, isSaving, maybeError, succeeded, toWrite, update, view };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Binding, HELP_KEYS, InitConfig, Message, Model, OutMessage, ViewInputs, id, init, isOpen, open, toKeymapGroups, update, view } from "./key-help.js";
|
|
2
|
+
declare namespace index_d_exports {
|
|
3
|
+
export { Binding, HELP_KEYS, InitConfig, Message, Model, OutMessage, ViewInputs, id, init, isOpen, open, toKeymapGroups, update, view };
|
|
4
|
+
}
|
|
5
|
+
export { type Binding, HELP_KEYS, type InitConfig, Message, Model, OutMessage, type ViewInputs, id, index_d_exports, init, isOpen, open, toKeymapGroups, update, view };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { HELP_KEYS, Message, Model, OutMessage, id, init, isOpen, open, toKeymapGroups, update, view } from "./key-help.js";
|
|
4
|
+
// src/key-help/index.ts
|
|
5
|
+
var key_help_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
HELP_KEYS: () => __foldkitBrandViewResult((HELP_KEYS), "@gjermundgaraba/pixel-paper/key-help/index.js#HELP_KEYS"),
|
|
7
|
+
Message: () => __foldkitBrandViewResult((Message), "@gjermundgaraba/pixel-paper/key-help/index.js#Message"),
|
|
8
|
+
Model: () => __foldkitBrandViewResult((Model), "@gjermundgaraba/pixel-paper/key-help/index.js#Model"),
|
|
9
|
+
OutMessage: () => __foldkitBrandViewResult((OutMessage), "@gjermundgaraba/pixel-paper/key-help/index.js#OutMessage"),
|
|
10
|
+
id: () => __foldkitBrandViewResult((id), "@gjermundgaraba/pixel-paper/key-help/index.js#id"),
|
|
11
|
+
init: () => __foldkitBrandViewResult((init), "@gjermundgaraba/pixel-paper/key-help/index.js#init"),
|
|
12
|
+
isOpen: () => __foldkitBrandViewResult((isOpen), "@gjermundgaraba/pixel-paper/key-help/index.js#isOpen"),
|
|
13
|
+
open: () => __foldkitBrandViewResult((open), "@gjermundgaraba/pixel-paper/key-help/index.js#open"),
|
|
14
|
+
toKeymapGroups: () => __foldkitBrandViewResult((toKeymapGroups), "@gjermundgaraba/pixel-paper/key-help/index.js#toKeymapGroups"),
|
|
15
|
+
update: () => __foldkitBrandViewResult((update), "@gjermundgaraba/pixel-paper/key-help/index.js#update"),
|
|
16
|
+
view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/key-help/index.js#view")
|
|
17
|
+
});
|
|
18
|
+
export { HELP_KEYS, Message, Model, OutMessage, id, init, isOpen, key_help_exports, open, toKeymapGroups, update, view };
|