@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,278 @@
|
|
|
1
|
+
import { Option, Schema } from "effect";
|
|
2
|
+
import { ChildAttribute, Html } from "foldkit/html";
|
|
3
|
+
import * as Mount from "foldkit/mount";
|
|
4
|
+
import * as Update from "foldkit/update";
|
|
5
|
+
/** Schema for a pixel-paper dialog: the `@foldkit/ui` Dialog it is built on. */
|
|
6
|
+
export declare const Model: Schema.Struct<{
|
|
7
|
+
readonly dialog: Schema.Struct<{
|
|
8
|
+
readonly id: Schema.String;
|
|
9
|
+
readonly isOpen: Schema.Boolean;
|
|
10
|
+
readonly isAnimated: Schema.Boolean;
|
|
11
|
+
readonly animation: Schema.Struct<{
|
|
12
|
+
readonly id: Schema.String;
|
|
13
|
+
readonly isShowing: Schema.Boolean;
|
|
14
|
+
readonly transitionState: Schema.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
|
|
15
|
+
readonly transitionGeneration: Schema.Number;
|
|
16
|
+
}>;
|
|
17
|
+
readonly maybeFocusSelector: Schema.Option<Schema.String>;
|
|
18
|
+
}>;
|
|
19
|
+
}>;
|
|
20
|
+
export type Model = typeof Model.Type;
|
|
21
|
+
/** Where the card hangs: `Center`, or `Top`, 18% down, for a command palette. */
|
|
22
|
+
export declare const Placement: Schema.Literals<readonly ["Center", "Top"]>;
|
|
23
|
+
export type Placement = typeof Placement.Type;
|
|
24
|
+
/** Union of all Messages a dialog can produce. `PressedActionKey` is a key in the action bar
|
|
25
|
+
* that moved focus there (the Mount already moved it); nothing in the Model follows it. */
|
|
26
|
+
export declare const Message: import("foldkit/message").MessageUnion<{
|
|
27
|
+
readonly GotDialogMessage: {
|
|
28
|
+
message: import("foldkit/message").MessageUnion<{
|
|
29
|
+
readonly RequestedOpen: {};
|
|
30
|
+
readonly RequestedClose: {};
|
|
31
|
+
readonly SucceededShowDialog: {};
|
|
32
|
+
readonly FailedShowDialog: {};
|
|
33
|
+
readonly SucceededAcquireResources: {};
|
|
34
|
+
readonly FailedAcquireResources: {};
|
|
35
|
+
readonly CompletedCloseDialog: {};
|
|
36
|
+
readonly Unmounted: {};
|
|
37
|
+
readonly CompletedReleaseDialogResources: {};
|
|
38
|
+
readonly GotAnimationMessage: {
|
|
39
|
+
message: import("foldkit/message").MessageUnion<{
|
|
40
|
+
readonly Showed: {};
|
|
41
|
+
readonly Hid: {};
|
|
42
|
+
readonly CompletedWaitForPaint: {
|
|
43
|
+
generation: Schema.Number;
|
|
44
|
+
};
|
|
45
|
+
readonly EndedAnimation: {
|
|
46
|
+
generation: Schema.Number;
|
|
47
|
+
};
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
readonly PressedActionKey: {
|
|
53
|
+
direction: Schema.Literals<readonly ["Previous", "Next"]>;
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
export type Message = typeof Message.Type;
|
|
57
|
+
/** Union of OutMessages a dialog reports to its parent: the reader closed it (Escape, a click
|
|
58
|
+
* on the veil, a close button). `open` and `close`, which the parent calls, report nothing. */
|
|
59
|
+
export declare const OutMessage: import("foldkit/message").MessageUnion<{
|
|
60
|
+
readonly Closed: {};
|
|
61
|
+
}>;
|
|
62
|
+
export type OutMessage = typeof OutMessage.Type;
|
|
63
|
+
/** Configuration for creating a dialog with `init`. The `id` must be unique in the document. */
|
|
64
|
+
export type InitConfig = Readonly<{
|
|
65
|
+
id: string;
|
|
66
|
+
}>;
|
|
67
|
+
/** Creates a closed dialog. */
|
|
68
|
+
export declare const init: (config: InitConfig) => Model;
|
|
69
|
+
/** The dialog's id, unique in the document. */
|
|
70
|
+
export declare const id: (model: Model) => string;
|
|
71
|
+
/** Whether the dialog is open. */
|
|
72
|
+
export declare const isOpen: (model: Model) => boolean;
|
|
73
|
+
/** What a dialog's update reads from its parent as a Message arrives. */
|
|
74
|
+
export type UpdateContext = Readonly<{
|
|
75
|
+
/** The reader may not walk away from the work running now (a save whose failure must land
|
|
76
|
+
* in this dialog): Escape, a press on the veil and a control given the `closeButton` group
|
|
77
|
+
* change nothing and report no `Closed`. Read it from the parent's own state as the
|
|
78
|
+
* Message arrives (`isSaving(model)`), so it holds exactly while the work runs, however
|
|
79
|
+
* soon after the start a key comes. */
|
|
80
|
+
isCloseHeld: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
/** Processes a dialog Message and returns the next Model, Commands and OutMessage. */
|
|
83
|
+
export declare const update: (model: Model, message: Message, context?: UpdateContext) => Readonly<{
|
|
84
|
+
model: {
|
|
85
|
+
readonly dialog: {
|
|
86
|
+
readonly id: string;
|
|
87
|
+
readonly isOpen: boolean;
|
|
88
|
+
readonly isAnimated: boolean;
|
|
89
|
+
readonly animation: {
|
|
90
|
+
readonly id: string;
|
|
91
|
+
readonly isShowing: boolean;
|
|
92
|
+
readonly transitionState: "EnterAnimating" | "EnterStart" | "Idle" | "LeaveAnimating" | "LeaveStart";
|
|
93
|
+
readonly transitionGeneration: number;
|
|
94
|
+
};
|
|
95
|
+
readonly maybeFocusSelector: Option.Option<string>;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
commands?: Update.Commands<{
|
|
99
|
+
readonly _tag: "GotDialogMessage";
|
|
100
|
+
readonly message: {
|
|
101
|
+
readonly _tag: "CompletedCloseDialog";
|
|
102
|
+
} | {
|
|
103
|
+
readonly _tag: "CompletedReleaseDialogResources";
|
|
104
|
+
} | {
|
|
105
|
+
readonly _tag: "FailedAcquireResources";
|
|
106
|
+
} | {
|
|
107
|
+
readonly _tag: "FailedShowDialog";
|
|
108
|
+
} | {
|
|
109
|
+
readonly _tag: "GotAnimationMessage";
|
|
110
|
+
readonly message: {
|
|
111
|
+
readonly _tag: "CompletedWaitForPaint";
|
|
112
|
+
readonly generation: number;
|
|
113
|
+
} | {
|
|
114
|
+
readonly _tag: "EndedAnimation";
|
|
115
|
+
readonly generation: number;
|
|
116
|
+
} | {
|
|
117
|
+
readonly _tag: "Hid";
|
|
118
|
+
} | {
|
|
119
|
+
readonly _tag: "Showed";
|
|
120
|
+
};
|
|
121
|
+
} | {
|
|
122
|
+
readonly _tag: "RequestedClose";
|
|
123
|
+
} | {
|
|
124
|
+
readonly _tag: "RequestedOpen";
|
|
125
|
+
} | {
|
|
126
|
+
readonly _tag: "SucceededAcquireResources";
|
|
127
|
+
} | {
|
|
128
|
+
readonly _tag: "SucceededShowDialog";
|
|
129
|
+
} | {
|
|
130
|
+
readonly _tag: "Unmounted";
|
|
131
|
+
};
|
|
132
|
+
} | {
|
|
133
|
+
readonly _tag: "PressedActionKey";
|
|
134
|
+
readonly direction: "Next" | "Previous";
|
|
135
|
+
}, never>;
|
|
136
|
+
outMessage?: {
|
|
137
|
+
readonly _tag: "Closed";
|
|
138
|
+
};
|
|
139
|
+
}>;
|
|
140
|
+
/** Opens the dialog: focus moves to the element given the `initialFocus` group, else to the
|
|
141
|
+
* first control, and returns to where it was when the dialog closes. */
|
|
142
|
+
export declare const open: (model: Model) => Update.Return<Model, Message>;
|
|
143
|
+
/** Closes the dialog without reporting `Closed`. */
|
|
144
|
+
export declare const close: (model: Model) => Update.Return<Model, Message>;
|
|
145
|
+
/** The action bar's keys: h or ←, and l or →, move focus between its actions (see
|
|
146
|
+
* `moveActionFocus`). Attached by the `actionBar` group. In a Scene, resolve it with
|
|
147
|
+
* `sceneMounts`. */
|
|
148
|
+
export declare const BindActionKeys: Mount.MountDefinitionNoArgs<"BindActionKeys", {
|
|
149
|
+
readonly _tag: "PressedActionKey";
|
|
150
|
+
readonly direction: "Next" | "Previous";
|
|
151
|
+
}>;
|
|
152
|
+
/** What a parent's Scene resolves an open dialog's Mounts with (`@foldkit/ui`'s resources,
|
|
153
|
+
* then the action bar's keys), each with a Message that changes nothing:
|
|
154
|
+
* `Scene.Mount.resolveAll(...Dialog.sceneMounts)`. It serves every dialog built on this one
|
|
155
|
+
* (ConfirmDialog, KeyHelp, CommandPalette), since a Scene lifts the Messages for it. */
|
|
156
|
+
export declare const sceneMounts: readonly [readonly [Mount.MountDefinitionWithArgs<"AcquireResources", {
|
|
157
|
+
id: Schema.String;
|
|
158
|
+
focusSelector: Schema.String;
|
|
159
|
+
}, {
|
|
160
|
+
readonly _tag: "SucceededAcquireResources";
|
|
161
|
+
} | {
|
|
162
|
+
readonly _tag: "FailedAcquireResources";
|
|
163
|
+
}>, {
|
|
164
|
+
readonly _tag: "SucceededAcquireResources";
|
|
165
|
+
}], readonly [Mount.MountDefinitionNoArgs<"BindActionKeys", {
|
|
166
|
+
readonly _tag: "PressedActionKey";
|
|
167
|
+
readonly direction: "Next" | "Previous";
|
|
168
|
+
}>, {
|
|
169
|
+
readonly _tag: "PressedActionKey";
|
|
170
|
+
readonly direction: "Next" | "Previous";
|
|
171
|
+
}]];
|
|
172
|
+
/** Attribute groups a dialog hands its content. Spread each onto the element it names; a Card
|
|
173
|
+
* takes `title` and `actionBar` directly. None of them carries a class. */
|
|
174
|
+
export type RenderInfo = Readonly<{
|
|
175
|
+
/** The heading that names the dialog. Leave it unspread when the dialog has a `label`. */
|
|
176
|
+
title: readonly ChildAttribute[];
|
|
177
|
+
/** The text that says what the dialog asks; set `hasDescription` when it is rendered. */
|
|
178
|
+
description: readonly ChildAttribute[];
|
|
179
|
+
/** The control that takes focus when the dialog opens. */
|
|
180
|
+
initialFocus: readonly ChildAttribute[];
|
|
181
|
+
/** A control that closes the dialog: a close glyph, a cancel button. */
|
|
182
|
+
closeButton: readonly ChildAttribute[];
|
|
183
|
+
/** The card's action bar: h or ←, and l or →, move focus between its actions. */
|
|
184
|
+
actionBar: readonly ChildAttribute[];
|
|
185
|
+
}>;
|
|
186
|
+
/** Per-render inputs passed to `view` through `h.submodel`'s `viewInputs`. */
|
|
187
|
+
export type ViewInputs = Readonly<{
|
|
188
|
+
/** The dialog's content, one Card. A function because it receives the attribute groups. */
|
|
189
|
+
toView: (render: RenderInfo) => Html;
|
|
190
|
+
/** The dialog's name when no heading in it says it (a command palette): printed for
|
|
191
|
+
* screen readers only. Otherwise the content's heading names it, through `title`. */
|
|
192
|
+
label?: string;
|
|
193
|
+
/** An alert dialog: a question that interrupts, such as a confirm. */
|
|
194
|
+
isAlert?: boolean;
|
|
195
|
+
placement?: Placement;
|
|
196
|
+
hasDescription?: boolean;
|
|
197
|
+
/** The page's live region (`Announcer.view`) and toast stack, while this is the topmost
|
|
198
|
+
* open dialog: the page outside it is inert and hidden from screen readers. Rendered
|
|
199
|
+
* inside the dialog, outside the card. A function, so markup with the application's
|
|
200
|
+
* handlers (the toasts' buttons) is built in the application's boundary. `undefined` while
|
|
201
|
+
* another dialog is the topmost: the application decides the host on every render. */
|
|
202
|
+
toLiveRegionView?: (() => Html) | undefined;
|
|
203
|
+
}>;
|
|
204
|
+
/**
|
|
205
|
+
* A modal dialog on the ink veil with its checker grain, built on `@foldkit/ui`'s Dialog. It
|
|
206
|
+
* opens with `show()` in place, not in the top layer: Foldkit makes the page behind it inert
|
|
207
|
+
* and hidden from screen readers, traps focus, closes it on Escape and on a click on the veil
|
|
208
|
+
* (`.veil-backdrop`, under `.veil-pad`, which lets a click through everywhere but on the
|
|
209
|
+
* card), and returns focus on close. The content comes from `toView`, usually one Card given
|
|
210
|
+
* the `title` and `actionBar` groups.
|
|
211
|
+
*/
|
|
212
|
+
export declare const view: import("foldkit/submodel").View<{
|
|
213
|
+
readonly dialog: {
|
|
214
|
+
readonly id: string;
|
|
215
|
+
readonly isOpen: boolean;
|
|
216
|
+
readonly isAnimated: boolean;
|
|
217
|
+
readonly animation: {
|
|
218
|
+
readonly id: string;
|
|
219
|
+
readonly isShowing: boolean;
|
|
220
|
+
readonly transitionState: "EnterAnimating" | "EnterStart" | "Idle" | "LeaveAnimating" | "LeaveStart";
|
|
221
|
+
readonly transitionGeneration: number;
|
|
222
|
+
};
|
|
223
|
+
readonly maybeFocusSelector: Option.Option<string>;
|
|
224
|
+
};
|
|
225
|
+
}, {
|
|
226
|
+
readonly _tag: "GotDialogMessage";
|
|
227
|
+
readonly message: {
|
|
228
|
+
readonly _tag: "CompletedCloseDialog";
|
|
229
|
+
} | {
|
|
230
|
+
readonly _tag: "CompletedReleaseDialogResources";
|
|
231
|
+
} | {
|
|
232
|
+
readonly _tag: "FailedAcquireResources";
|
|
233
|
+
} | {
|
|
234
|
+
readonly _tag: "FailedShowDialog";
|
|
235
|
+
} | {
|
|
236
|
+
readonly _tag: "GotAnimationMessage";
|
|
237
|
+
readonly message: {
|
|
238
|
+
readonly _tag: "CompletedWaitForPaint";
|
|
239
|
+
readonly generation: number;
|
|
240
|
+
} | {
|
|
241
|
+
readonly _tag: "EndedAnimation";
|
|
242
|
+
readonly generation: number;
|
|
243
|
+
} | {
|
|
244
|
+
readonly _tag: "Hid";
|
|
245
|
+
} | {
|
|
246
|
+
readonly _tag: "Showed";
|
|
247
|
+
};
|
|
248
|
+
} | {
|
|
249
|
+
readonly _tag: "RequestedClose";
|
|
250
|
+
} | {
|
|
251
|
+
readonly _tag: "RequestedOpen";
|
|
252
|
+
} | {
|
|
253
|
+
readonly _tag: "SucceededAcquireResources";
|
|
254
|
+
} | {
|
|
255
|
+
readonly _tag: "SucceededShowDialog";
|
|
256
|
+
} | {
|
|
257
|
+
readonly _tag: "Unmounted";
|
|
258
|
+
};
|
|
259
|
+
} | {
|
|
260
|
+
readonly _tag: "PressedActionKey";
|
|
261
|
+
readonly direction: "Next" | "Previous";
|
|
262
|
+
}, Readonly<{
|
|
263
|
+
/** The dialog's content, one Card. A function because it receives the attribute groups. */
|
|
264
|
+
toView: (render: RenderInfo) => Html;
|
|
265
|
+
/** The dialog's name when no heading in it says it (a command palette): printed for
|
|
266
|
+
* screen readers only. Otherwise the content's heading names it, through `title`. */
|
|
267
|
+
label?: string;
|
|
268
|
+
/** An alert dialog: a question that interrupts, such as a confirm. */
|
|
269
|
+
isAlert?: boolean;
|
|
270
|
+
placement?: Placement;
|
|
271
|
+
hasDescription?: boolean;
|
|
272
|
+
/** The page's live region (`Announcer.view`) and toast stack, while this is the topmost
|
|
273
|
+
* open dialog: the page outside it is inert and hidden from screen readers. Rendered
|
|
274
|
+
* inside the dialog, outside the card. A function, so markup with the application's
|
|
275
|
+
* handlers (the toasts' buttons) is built in the application's boundary. `undefined` while
|
|
276
|
+
* another dialog is the topmost: the application decides the host on every render. */
|
|
277
|
+
toLiveRegionView?: (() => Html) | undefined;
|
|
278
|
+
}>>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { isPlain } from "../keys/keys.js";
|
|
4
|
+
import { foldDialog } from "./fold.js";
|
|
5
|
+
import { Array, Match, Option, Schema, pipe } from "effect";
|
|
6
|
+
import { defineMessageUnion } from "foldkit/message";
|
|
7
|
+
import { Dialog } from "@foldkit/ui";
|
|
8
|
+
import { childAttributes } from "foldkit/html";
|
|
9
|
+
import * as Mount from "foldkit/mount";
|
|
10
|
+
import { modifyFields } from "foldkit/struct";
|
|
11
|
+
import { defineView } from "foldkit/submodel";
|
|
12
|
+
import * as Dom from "foldkit/dom";
|
|
13
|
+
import { constUndefined } from "effect/Function";
|
|
14
|
+
// src/dialog/dialog.ts
|
|
15
|
+
var dialog_exports = /* @__PURE__ */ __exportAll({
|
|
16
|
+
BindActionKeys: () => __foldkitBrandViewResult((BindActionKeys), "@gjermundgaraba/pixel-paper/dialog/dialog.js#BindActionKeys"),
|
|
17
|
+
FREE: () => __foldkitBrandViewResult((FREE), "@gjermundgaraba/pixel-paper/dialog/dialog.js#FREE"),
|
|
18
|
+
Message: () => __foldkitBrandViewResult((Message), "@gjermundgaraba/pixel-paper/dialog/dialog.js#Message"),
|
|
19
|
+
Model: () => __foldkitBrandViewResult((Model), "@gjermundgaraba/pixel-paper/dialog/dialog.js#Model"),
|
|
20
|
+
OutMessage: () => __foldkitBrandViewResult((OutMessage), "@gjermundgaraba/pixel-paper/dialog/dialog.js#OutMessage"),
|
|
21
|
+
Placement: () => __foldkitBrandViewResult((Placement), "@gjermundgaraba/pixel-paper/dialog/dialog.js#Placement"),
|
|
22
|
+
close: () => __foldkitBrandViewResult((close), "@gjermundgaraba/pixel-paper/dialog/dialog.js#close"),
|
|
23
|
+
id: () => __foldkitBrandViewResult((id), "@gjermundgaraba/pixel-paper/dialog/dialog.js#id"),
|
|
24
|
+
init: () => __foldkitBrandViewResult((init), "@gjermundgaraba/pixel-paper/dialog/dialog.js#init"),
|
|
25
|
+
isOpen: () => __foldkitBrandViewResult((isOpen), "@gjermundgaraba/pixel-paper/dialog/dialog.js#isOpen"),
|
|
26
|
+
moveActionFocus: () => __foldkitBrandViewResult((moveActionFocus), "@gjermundgaraba/pixel-paper/dialog/dialog.js#moveActionFocus"),
|
|
27
|
+
open: () => __foldkitBrandViewResult((open), "@gjermundgaraba/pixel-paper/dialog/dialog.js#open"),
|
|
28
|
+
sceneMounts: () => __foldkitBrandViewResult((sceneMounts), "@gjermundgaraba/pixel-paper/dialog/dialog.js#sceneMounts"),
|
|
29
|
+
update: () => __foldkitBrandViewResult((update), "@gjermundgaraba/pixel-paper/dialog/dialog.js#update"),
|
|
30
|
+
view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/dialog/dialog.js#view")
|
|
31
|
+
});
|
|
32
|
+
/** Schema for a pixel-paper dialog: the `@foldkit/ui` Dialog it is built on. */
|
|
33
|
+
const Model = Schema.Struct({ dialog: Dialog.Model });
|
|
34
|
+
const ActionDirection = Schema.Literals(["Previous", "Next"]);
|
|
35
|
+
/** Where the card hangs: `Center`, or `Top`, 18% down, for a command palette. */
|
|
36
|
+
const Placement = Schema.Literals(["Center", "Top"]);
|
|
37
|
+
/** Union of all Messages a dialog can produce. `PressedActionKey` is a key in the action bar
|
|
38
|
+
* that moved focus there (the Mount already moved it); nothing in the Model follows it. */
|
|
39
|
+
const Message = defineMessageUnion({
|
|
40
|
+
GotDialogMessage: { message: Dialog.Message },
|
|
41
|
+
PressedActionKey: { direction: ActionDirection }
|
|
42
|
+
});
|
|
43
|
+
/** Union of OutMessages a dialog reports to its parent: the reader closed it (Escape, a click
|
|
44
|
+
* on the veil, a close button). `open` and `close`, which the parent calls, report nothing. */
|
|
45
|
+
const OutMessage = defineMessageUnion({ Closed: {} });
|
|
46
|
+
/** Creates a closed dialog. */
|
|
47
|
+
const init = (config) => (__foldkitBrandViewResult(({ dialog: Dialog.init({ id: config.id }) }), "@gjermundgaraba/pixel-paper/dialog/dialog.js#init~2"));
|
|
48
|
+
/** The dialog's id, unique in the document. */
|
|
49
|
+
const id = (model) => __foldkitBrandViewResult((model.dialog.id), "@gjermundgaraba/pixel-paper/dialog/dialog.js#id~2");
|
|
50
|
+
/** Whether the dialog is open. */
|
|
51
|
+
const isOpen = (model) => __foldkitBrandViewResult((model.dialog.isOpen), "@gjermundgaraba/pixel-paper/dialog/dialog.js#isOpen~2");
|
|
52
|
+
const toOutMessage = Dialog.OutMessage.match({
|
|
53
|
+
Opened: constUndefined,
|
|
54
|
+
Closed: () => __foldkitBrandViewResult((OutMessage.Closed()), "@gjermundgaraba/pixel-paper/dialog/dialog.js#Closed")
|
|
55
|
+
});
|
|
56
|
+
const dialogFold = foldDialog(Dialog, {
|
|
57
|
+
read: (model) => __foldkitBrandViewResult((model.dialog), "@gjermundgaraba/pixel-paper/dialog/dialog.js#read"),
|
|
58
|
+
write: (model, nextDialog) => __foldkitBrandViewResult((modifyFields(model, { dialog: () => __foldkitBrandViewResult((nextDialog), "@gjermundgaraba/pixel-paper/dialog/dialog.js#dialog") })), "@gjermundgaraba/pixel-paper/dialog/dialog.js#write"),
|
|
59
|
+
toParentMessage: (message) => __foldkitBrandViewResult((Message.GotDialogMessage({ message })), "@gjermundgaraba/pixel-paper/dialog/dialog.js#toParentMessage"),
|
|
60
|
+
toParentOutMessage: toOutMessage
|
|
61
|
+
});
|
|
62
|
+
const FREE = { isCloseHeld: false };
|
|
63
|
+
const isHeldClose = (context, message) => __foldkitBrandViewResult((context.isCloseHeld && message._tag === "RequestedClose"), "@gjermundgaraba/pixel-paper/dialog/dialog.js#isHeldClose");
|
|
64
|
+
/** Processes a dialog Message and returns the next Model, Commands and OutMessage. */
|
|
65
|
+
const update = (model, message, context = FREE) => __foldkitBrandViewResult((Message.match(message, {
|
|
66
|
+
GotDialogMessage: ({ message: dialogMessage }) => __foldkitBrandViewResult((isHeldClose(context, dialogMessage) ? { model } : dialogFold.update(model, dialogMessage)), "@gjermundgaraba/pixel-paper/dialog/dialog.js#GotDialogMessage"),
|
|
67
|
+
PressedActionKey: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/dialog/dialog.js#PressedActionKey"))
|
|
68
|
+
})), "@gjermundgaraba/pixel-paper/dialog/dialog.js#update~2");
|
|
69
|
+
/** Opens the dialog: focus moves to the element given the `initialFocus` group, else to the
|
|
70
|
+
* first control, and returns to where it was when the dialog closes. */
|
|
71
|
+
const open = (model) => __foldkitBrandViewResult((dialogFold.open(model)), "@gjermundgaraba/pixel-paper/dialog/dialog.js#open~2");
|
|
72
|
+
/** Closes the dialog without reporting `Closed`. */
|
|
73
|
+
const close = (model) => __foldkitBrandViewResult((dialogFold.close(model)), "@gjermundgaraba/pixel-paper/dialog/dialog.js#close~2");
|
|
74
|
+
const ACTION_BAR_ATTRIBUTE = "data-pixel-paper-action-bar";
|
|
75
|
+
const ACTION_SELECTOR = "button:not(:disabled), a[href]";
|
|
76
|
+
const isInBarItself = (bar, action) => __foldkitBrandViewResult((action.closest(`[${ACTION_BAR_ATTRIBUTE}]`) === bar), "@gjermundgaraba/pixel-paper/dialog/dialog.js#isInBarItself");
|
|
77
|
+
const isInBarsDialog = (bar, action) => __foldkitBrandViewResult((action.closest("dialog") === bar.closest("dialog")), "@gjermundgaraba/pixel-paper/dialog/dialog.js#isInBarsDialog");
|
|
78
|
+
const isOutsidePopover = (action) => __foldkitBrandViewResult((action.closest("[popover]") === null), "@gjermundgaraba/pixel-paper/dialog/dialog.js#isOutsidePopover");
|
|
79
|
+
const ownedActions = (bar) => __foldkitBrandViewResult((Array.filter(Array.fromIterable(bar.querySelectorAll(ACTION_SELECTOR)), (action) => __foldkitBrandViewResult((isInBarItself(bar, action) && isInBarsDialog(bar, action) && isOutsidePopover(action)), "@gjermundgaraba/pixel-paper/dialog/dialog.js#anonymous"))), "@gjermundgaraba/pixel-paper/dialog/dialog.js#ownedActions");
|
|
80
|
+
const isUnhandledPlainKey = (event) => __foldkitBrandViewResult((!event.isComposing && !event.defaultPrevented && isPlain(event)), "@gjermundgaraba/pixel-paper/dialog/dialog.js#isUnhandledPlainKey");
|
|
81
|
+
const actionBeside = (actions, target, direction) => __foldkitBrandViewResult((Option.flatMap(Array.findFirstIndex(actions, (action) => __foldkitBrandViewResult((action === target), "@gjermundgaraba/pixel-paper/dialog/dialog.js#anonymous~2")), (index) => __foldkitBrandViewResult((Array.get(actions, index + (direction === "Previous" ? -1 : 1))), "@gjermundgaraba/pixel-paper/dialog/dialog.js#anonymous~3"))), "@gjermundgaraba/pixel-paper/dialog/dialog.js#actionBeside");
|
|
82
|
+
const toActionDirection = (key) => __foldkitBrandViewResult((Match.value(key).pipe(Match.withReturnType(), Match.whenOr("h", "ArrowLeft", () => __foldkitBrandViewResult((Option.some("Previous")), "@gjermundgaraba/pixel-paper/dialog/dialog.js#anonymous~4")), Match.whenOr("l", "ArrowRight", () => __foldkitBrandViewResult((Option.some("Next")), "@gjermundgaraba/pixel-paper/dialog/dialog.js#anonymous~5")), Match.orElse(() => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/dialog/dialog.js#anonymous~6")))), "@gjermundgaraba/pixel-paper/dialog/dialog.js#toActionDirection");
|
|
83
|
+
const moveActionFocus = (bar, event) => {
|
|
84
|
+
if (!isUnhandledPlainKey(event)) return __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/dialog/dialog.js#moveActionFocus~2");
|
|
85
|
+
return __foldkitBrandViewResult((pipe(toActionDirection(event.key), Option.flatMap((direction) => __foldkitBrandViewResult((Option.map(actionBeside(ownedActions(bar), event.target, direction), (next) => {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
next.focus();
|
|
88
|
+
return __foldkitBrandViewResult((direction), "@gjermundgaraba/pixel-paper/dialog/dialog.js#anonymous~8");
|
|
89
|
+
})), "@gjermundgaraba/pixel-paper/dialog/dialog.js#anonymous~7")))), "@gjermundgaraba/pixel-paper/dialog/dialog.js#moveActionFocus~2");
|
|
90
|
+
};
|
|
91
|
+
/** The action bar's keys: h or ←, and l or →, move focus between its actions (see
|
|
92
|
+
* `moveActionFocus`). Attached by the `actionBar` group. In a Scene, resolve it with
|
|
93
|
+
* `sceneMounts`. */
|
|
94
|
+
const BindActionKeys = Mount.defineStream("BindActionKeys", {
|
|
95
|
+
messages: [Message.PressedActionKey],
|
|
96
|
+
execute: ({ element }) => __foldkitBrandViewResult((Dom.streamFromEventFilterMap({
|
|
97
|
+
target: element,
|
|
98
|
+
type: "keydown",
|
|
99
|
+
filterMapEvent: (event) => __foldkitBrandViewResult((Option.map(moveActionFocus(element, event), (direction) => __foldkitBrandViewResult((Message.PressedActionKey({ direction })), "@gjermundgaraba/pixel-paper/dialog/dialog.js#anonymous~9"))), "@gjermundgaraba/pixel-paper/dialog/dialog.js#filterMapEvent")
|
|
100
|
+
})), "@gjermundgaraba/pixel-paper/dialog/dialog.js#execute")
|
|
101
|
+
});
|
|
102
|
+
/** What a parent's Scene resolves an open dialog's Mounts with (`@foldkit/ui`'s resources,
|
|
103
|
+
* then the action bar's keys), each with a Message that changes nothing:
|
|
104
|
+
* `Scene.Mount.resolveAll(...Dialog.sceneMounts)`. It serves every dialog built on this one
|
|
105
|
+
* (ConfirmDialog, KeyHelp, CommandPalette), since a Scene lifts the Messages for it. */
|
|
106
|
+
const sceneMounts = [[Dialog.AcquireResources, Dialog.Message.SucceededAcquireResources()], [BindActionKeys, Message.PressedActionKey({ direction: "Next" })]];
|
|
107
|
+
/**
|
|
108
|
+
* A modal dialog on the ink veil with its checker grain, built on `@foldkit/ui`'s Dialog. It
|
|
109
|
+
* opens with `show()` in place, not in the top layer: Foldkit makes the page behind it inert
|
|
110
|
+
* and hidden from screen readers, traps focus, closes it on Escape and on a click on the veil
|
|
111
|
+
* (`.veil-backdrop`, under `.veil-pad`, which lets a click through everywhere but on the
|
|
112
|
+
* card), and returns focus on close. The content comes from `toView`, usually one Card given
|
|
113
|
+
* the `title` and `actionBar` groups.
|
|
114
|
+
*/
|
|
115
|
+
const view = defineView((model, viewInputs, h) => {
|
|
116
|
+
const { toView, label, isAlert = false, placement = "Center", hasDescription = false, toLiveRegionView } = viewInputs;
|
|
117
|
+
const actionBar = childAttributes([h.Attribute(ACTION_BAR_ATTRIBUTE, ""), h.OnMount(BindActionKeys())]);
|
|
118
|
+
const veilView = (render) => __foldkitBrandViewResult((h.dialog([
|
|
119
|
+
...render.dialog,
|
|
120
|
+
...isAlert ? [h.Role("alertdialog")] : [],
|
|
121
|
+
h.Class("veil")
|
|
122
|
+
], render.isVisible ? [
|
|
123
|
+
h.div([...render.backdrop, h.Class("veil-backdrop")]),
|
|
124
|
+
...label === void 0 ? [] : [h.span([...render.title, h.Class("sr-only")], [label])],
|
|
125
|
+
h.div([...render.panel, h.Class(placement === "Top" ? "veil-pad top" : "veil-pad")], [toView({
|
|
126
|
+
title: render.title,
|
|
127
|
+
description: render.description,
|
|
128
|
+
initialFocus: render.initialFocus,
|
|
129
|
+
closeButton: render.closeButton,
|
|
130
|
+
actionBar
|
|
131
|
+
})]),
|
|
132
|
+
...toLiveRegionView === void 0 ? [] : [toLiveRegionView()]
|
|
133
|
+
] : [])), "@gjermundgaraba/pixel-paper/dialog/dialog.js#veilView");
|
|
134
|
+
return __foldkitBrandViewResult((h.submodel({
|
|
135
|
+
slotId: id(model),
|
|
136
|
+
model: model.dialog,
|
|
137
|
+
view: Dialog.view,
|
|
138
|
+
viewInputs: {
|
|
139
|
+
hasDescription,
|
|
140
|
+
toView: veilView
|
|
141
|
+
},
|
|
142
|
+
toParentMessage: (message) => __foldkitBrandViewResult((Message.GotDialogMessage({ message })), "@gjermundgaraba/pixel-paper/dialog/dialog.js#toParentMessage~2")
|
|
143
|
+
})), "@gjermundgaraba/pixel-paper/dialog/dialog.js#anonymous~10");
|
|
144
|
+
});
|
|
145
|
+
export { BindActionKeys, FREE, Message, Model, OutMessage, Placement, close, dialog_exports, id, init, isOpen, moveActionFocus, open, sceneMounts, update, view };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { UpdateContext } from "./dialog.js";
|
|
2
|
+
import * as Update from "foldkit/update";
|
|
3
|
+
type ChildReturn<ChildModel, ChildMessage, ChildOutMessage> = Update.ReturnWithOutMessage<ChildModel, ChildMessage, ChildOutMessage>;
|
|
4
|
+
/** A dialog a parent holds: its update, and the steps that open and close it (`@foldkit/ui`'s
|
|
5
|
+
* Dialog, or pixel-paper's). */
|
|
6
|
+
export type DialogChild<ChildModel, ChildMessage, ChildOutMessage> = Readonly<{
|
|
7
|
+
update: (model: ChildModel, message: ChildMessage, context: UpdateContext) => ChildReturn<ChildModel, ChildMessage, ChildOutMessage>;
|
|
8
|
+
open: (model: ChildModel) => ChildReturn<ChildModel, ChildMessage, ChildOutMessage>;
|
|
9
|
+
close: (model: ChildModel) => ChildReturn<ChildModel, ChildMessage, ChildOutMessage>;
|
|
10
|
+
}>;
|
|
11
|
+
/** Where the parent keeps its dialog, and what the dialog's Messages and OutMessages become. */
|
|
12
|
+
export type DialogFoldConfig<ParentModel, ParentMessage, ParentOutMessage, ChildModel, ChildMessage, ChildOutMessage> = Readonly<{
|
|
13
|
+
read: (model: ParentModel) => ChildModel;
|
|
14
|
+
write: (model: ParentModel, nextDialog: ChildModel) => ParentModel;
|
|
15
|
+
toParentMessage: (message: ChildMessage) => ParentMessage;
|
|
16
|
+
/** The parent's OutMessage for one the dialog reports from its own update (Escape, the
|
|
17
|
+
* veil, a close button). Without it the dialog's OutMessages report nothing: a parent
|
|
18
|
+
* that reads `isOpen` when it needs to. */
|
|
19
|
+
toParentOutMessage?: (outMessage: ChildOutMessage) => ParentOutMessage | undefined;
|
|
20
|
+
/** Whether the dialog's ways out are held, read from the parent's own state as each
|
|
21
|
+
* Message arrives (`(model) => model.isSaving`). Free when not given. See
|
|
22
|
+
* `Dialog.UpdateContext`. */
|
|
23
|
+
isCloseHeld?: (model: ParentModel) => boolean;
|
|
24
|
+
}>;
|
|
25
|
+
/** The dialog folded into its parent: a dialog Message, and opening and closing it. */
|
|
26
|
+
export type DialogFold<ParentModel, ParentMessage, ParentOutMessage, ChildMessage> = Readonly<{
|
|
27
|
+
update: (model: ParentModel, message: ChildMessage) => Update.ReturnWithOutMessage<ParentModel, ParentMessage, ParentOutMessage>;
|
|
28
|
+
/** The update a parent that is itself a dialog (ConfirmDialog) runs with the hold its own
|
|
29
|
+
* parent gave it. */
|
|
30
|
+
updateWith: (context: UpdateContext) => (model: ParentModel, message: ChildMessage) => Update.ReturnWithOutMessage<ParentModel, ParentMessage, ParentOutMessage>;
|
|
31
|
+
open: (model: ParentModel) => Update.Return<ParentModel, ParentMessage>;
|
|
32
|
+
close: (model: ParentModel) => Update.Return<ParentModel, ParentMessage>;
|
|
33
|
+
}>;
|
|
34
|
+
/** Folds a dialog a parent always holds (`Dialog`, `ConfirmDialog`, `@foldkit/ui`'s Dialog):
|
|
35
|
+
* its update, `open` and `close`, each lifted into the parent's Model and Messages, in place
|
|
36
|
+
* of a `foldChild` and two `foldChildStep`s.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* const dialogFold = Dialog.foldDialog(Dialog, {
|
|
40
|
+
* read: (model: Model) => model.dialog,
|
|
41
|
+
* write: (model: Model, dialog: Dialog.Model) => modifyFields(model, { dialog: () => dialog }),
|
|
42
|
+
* toParentMessage: (message: Dialog.Message): Message => Message.GotDialogMessage({ message }),
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* `toParentMessage` returns the parent's whole Message, so the steps compose with the
|
|
47
|
+
* parent's own in `Update.combine`.
|
|
48
|
+
*
|
|
49
|
+
* A step the parent asked for reports nothing: `open` and `close` return the next Model and
|
|
50
|
+
* Commands, and the parent, which called them, attaches its own OutMessage where it has one
|
|
51
|
+
* (`pipe(dialogFold.close(model), Update.withOutMessage(…))`). Only the dialog's own Escape,
|
|
52
|
+
* veil or close button reports, through `update`, and only when `toParentOutMessage` is
|
|
53
|
+
* given; without it `update` reports nothing either.
|
|
54
|
+
*
|
|
55
|
+
* A parent that acts on what the dialog reports by changing its own Model (a ConfirmDialog's
|
|
56
|
+
* `Confirmed`) folds that update with `Update.foldChild` and its `foldOutMessage`. */
|
|
57
|
+
export declare const foldDialog: <ParentModel, ParentMessage, ChildModel, ChildMessage, ChildOutMessage, ParentOutMessage = never>(child: DialogChild<ChildModel, ChildMessage, ChildOutMessage>, config: DialogFoldConfig<ParentModel, ParentMessage, ParentOutMessage, ChildModel, ChildMessage, ChildOutMessage>) => DialogFold<ParentModel, ParentMessage, ParentOutMessage, ChildMessage>;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { Option } from "effect";
|
|
3
|
+
import * as Update from "foldkit/update";
|
|
4
|
+
// src/dialog/fold.ts
|
|
5
|
+
/** Folds a dialog a parent always holds (`Dialog`, `ConfirmDialog`, `@foldkit/ui`'s Dialog):
|
|
6
|
+
* its update, `open` and `close`, each lifted into the parent's Model and Messages, in place
|
|
7
|
+
* of a `foldChild` and two `foldChildStep`s.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const dialogFold = Dialog.foldDialog(Dialog, {
|
|
11
|
+
* read: (model: Model) => model.dialog,
|
|
12
|
+
* write: (model: Model, dialog: Dialog.Model) => modifyFields(model, { dialog: () => dialog }),
|
|
13
|
+
* toParentMessage: (message: Dialog.Message): Message => Message.GotDialogMessage({ message }),
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* `toParentMessage` returns the parent's whole Message, so the steps compose with the
|
|
18
|
+
* parent's own in `Update.combine`.
|
|
19
|
+
*
|
|
20
|
+
* A step the parent asked for reports nothing: `open` and `close` return the next Model and
|
|
21
|
+
* Commands, and the parent, which called them, attaches its own OutMessage where it has one
|
|
22
|
+
* (`pipe(dialogFold.close(model), Update.withOutMessage(…))`). Only the dialog's own Escape,
|
|
23
|
+
* veil or close button reports, through `update`, and only when `toParentOutMessage` is
|
|
24
|
+
* given; without it `update` reports nothing either.
|
|
25
|
+
*
|
|
26
|
+
* A parent that acts on what the dialog reports by changing its own Model (a ConfirmDialog's
|
|
27
|
+
* `Confirmed`) folds that update with `Update.foldChild` and its `foldOutMessage`. */
|
|
28
|
+
const foldDialog = (child, config) => {
|
|
29
|
+
const lift = {
|
|
30
|
+
read: (model) => __foldkitBrandViewResult((Option.some(config.read(model))), "@gjermundgaraba/pixel-paper/dialog/fold.js#read"),
|
|
31
|
+
write: config.write,
|
|
32
|
+
toParentMessage: config.toParentMessage
|
|
33
|
+
};
|
|
34
|
+
const foldOutMessage = () => __foldkitBrandViewResult(((model) => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba/pixel-paper/dialog/fold.js#anonymous"))), "@gjermundgaraba/pixel-paper/dialog/fold.js#foldOutMessage");
|
|
35
|
+
const { toParentOutMessage, isCloseHeld = () => __foldkitBrandViewResult((false), "@gjermundgaraba/pixel-paper/dialog/fold.js#anonymous~2") } = config;
|
|
36
|
+
const updateWith = (context) => {
|
|
37
|
+
const childUpdate = (model, message) => __foldkitBrandViewResult((child.update(model, message, context)), "@gjermundgaraba/pixel-paper/dialog/fold.js#childUpdate");
|
|
38
|
+
return __foldkitBrandViewResult((toParentOutMessage === void 0 ? Update.foldChild({
|
|
39
|
+
update: childUpdate,
|
|
40
|
+
...lift,
|
|
41
|
+
foldOutMessage
|
|
42
|
+
}) : Update.foldChild({
|
|
43
|
+
update: childUpdate,
|
|
44
|
+
...lift,
|
|
45
|
+
toParentOutMessage
|
|
46
|
+
})), "@gjermundgaraba/pixel-paper/dialog/fold.js#updateWith");
|
|
47
|
+
};
|
|
48
|
+
return __foldkitBrandViewResult(({
|
|
49
|
+
update: (model, message) => __foldkitBrandViewResult((updateWith({ isCloseHeld: isCloseHeld(model) })(model, message)), "@gjermundgaraba/pixel-paper/dialog/fold.js#update"),
|
|
50
|
+
updateWith,
|
|
51
|
+
open: Update.foldChildStep({
|
|
52
|
+
update: child.open,
|
|
53
|
+
...lift,
|
|
54
|
+
foldOutMessage
|
|
55
|
+
}),
|
|
56
|
+
close: Update.foldChildStep({
|
|
57
|
+
update: child.close,
|
|
58
|
+
...lift,
|
|
59
|
+
foldOutMessage
|
|
60
|
+
})
|
|
61
|
+
}), "@gjermundgaraba/pixel-paper/dialog/fold.js#foldDialog");
|
|
62
|
+
};
|
|
63
|
+
export { foldDialog };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BindActionKeys, InitConfig, Message, Model, OutMessage, RenderInfo, UpdateContext, ViewInputs, close, id, init, isOpen, open, sceneMounts, update, view } from "./dialog.js";
|
|
2
|
+
import { foldDialog } from "./fold.js";
|
|
3
|
+
declare namespace index_d_exports {
|
|
4
|
+
export { BindActionKeys, InitConfig, Message, Model, OutMessage, RenderInfo, UpdateContext, ViewInputs, close, foldDialog, id, init, isOpen, open, sceneMounts, update, view };
|
|
5
|
+
}
|
|
6
|
+
export { BindActionKeys, type InitConfig, Message, Model, OutMessage, type RenderInfo, type UpdateContext, type ViewInputs, close, foldDialog, id, index_d_exports, init, isOpen, open, sceneMounts, update, view };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { foldDialog } from "./fold.js";
|
|
4
|
+
import { BindActionKeys, Message, Model, OutMessage, close, id, init, isOpen, open, sceneMounts, update, view } from "./dialog.js";
|
|
5
|
+
// src/dialog/index.ts
|
|
6
|
+
var dialog_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
BindActionKeys: () => __foldkitBrandViewResult((BindActionKeys), "@gjermundgaraba/pixel-paper/dialog/index.js#BindActionKeys"),
|
|
8
|
+
Message: () => __foldkitBrandViewResult((Message), "@gjermundgaraba/pixel-paper/dialog/index.js#Message"),
|
|
9
|
+
Model: () => __foldkitBrandViewResult((Model), "@gjermundgaraba/pixel-paper/dialog/index.js#Model"),
|
|
10
|
+
OutMessage: () => __foldkitBrandViewResult((OutMessage), "@gjermundgaraba/pixel-paper/dialog/index.js#OutMessage"),
|
|
11
|
+
close: () => __foldkitBrandViewResult((close), "@gjermundgaraba/pixel-paper/dialog/index.js#close"),
|
|
12
|
+
foldDialog: () => __foldkitBrandViewResult((foldDialog), "@gjermundgaraba/pixel-paper/dialog/index.js#foldDialog"),
|
|
13
|
+
id: () => __foldkitBrandViewResult((id), "@gjermundgaraba/pixel-paper/dialog/index.js#id"),
|
|
14
|
+
init: () => __foldkitBrandViewResult((init), "@gjermundgaraba/pixel-paper/dialog/index.js#init"),
|
|
15
|
+
isOpen: () => __foldkitBrandViewResult((isOpen), "@gjermundgaraba/pixel-paper/dialog/index.js#isOpen"),
|
|
16
|
+
open: () => __foldkitBrandViewResult((open), "@gjermundgaraba/pixel-paper/dialog/index.js#open"),
|
|
17
|
+
sceneMounts: () => __foldkitBrandViewResult((sceneMounts), "@gjermundgaraba/pixel-paper/dialog/index.js#sceneMounts"),
|
|
18
|
+
update: () => __foldkitBrandViewResult((update), "@gjermundgaraba/pixel-paper/dialog/index.js#update"),
|
|
19
|
+
view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/dialog/index.js#view")
|
|
20
|
+
});
|
|
21
|
+
export { BindActionKeys, Message, Model, OutMessage, close, dialog_exports, foldDialog, id, init, isOpen, open, sceneMounts, update, view };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
/** Configuration for rendering a disclosure with `view`. */
|
|
3
|
+
export type ViewConfig<Message> = Readonly<{
|
|
4
|
+
/** Unique in the document; the button's and the body's ids derive from it. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** What opens, in pixel caps (`"edit grants"`, `"danger zone"`): the button's name. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Whether it is open, from the parent's Model. */
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
/** Dispatched with the new state when the line is pressed, or Enter or Space is pressed on
|
|
11
|
+
* it. Store it and pass it back in as `isOpen`. */
|
|
12
|
+
onToggle: (isOpen: boolean) => Message;
|
|
13
|
+
/** What hangs under the line while it is open. It stays on the page while closed (hidden),
|
|
14
|
+
* so a field in it keeps what was typed. */
|
|
15
|
+
body: ReadonlyArray<Html | string>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* A line that opens what is under it, built on `@foldkit/ui`'s Disclosure: the parent owns
|
|
19
|
+
* whether it is open. `div.disclosure > button.disclosure-summary[aria-expanded]` (the caret
|
|
20
|
+
* and the label) and `div.disclosure-body`, which hangs from the caret on a 1px
|
|
21
|
+
* rule guide. Open, the caret turns a quarter in one step. For what a reader opens on purpose
|
|
22
|
+
* (grants to edit, details, a danger zone), never to hide the one thing the screen is for.
|
|
23
|
+
*/
|
|
24
|
+
export declare const view: <Message>(config: ViewConfig<Message>, h: HtmlBuilder<Message>) => Html;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { view as view$1 } from "../glyph/glyph.js";
|
|
3
|
+
import { Disclosure } from "@foldkit/ui";
|
|
4
|
+
// src/disclosure/disclosure.ts
|
|
5
|
+
/**
|
|
6
|
+
* A line that opens what is under it, built on `@foldkit/ui`'s Disclosure: the parent owns
|
|
7
|
+
* whether it is open. `div.disclosure > button.disclosure-summary[aria-expanded]` (the caret
|
|
8
|
+
* and the label) and `div.disclosure-body`, which hangs from the caret on a 1px
|
|
9
|
+
* rule guide. Open, the caret turns a quarter in one step. For what a reader opens on purpose
|
|
10
|
+
* (grants to edit, details, a danger zone), never to hide the one thing the screen is for.
|
|
11
|
+
*/
|
|
12
|
+
const view = (config, h) => {
|
|
13
|
+
const { id, label, isOpen, onToggle, body } = config;
|
|
14
|
+
return __foldkitBrandViewResult((Disclosure.view({
|
|
15
|
+
id,
|
|
16
|
+
isOpen,
|
|
17
|
+
onToggle,
|
|
18
|
+
toView: (groups) => __foldkitBrandViewResult((h.div([h.Class("disclosure")], [h.button([...groups.button, h.Class("disclosure-summary")], [view$1({ name: "caret-right" }, h), h.span([h.Class("disclosure-label")], [label])]), h.div([
|
|
19
|
+
...groups.panel,
|
|
20
|
+
h.Hidden(!isOpen),
|
|
21
|
+
h.Class("disclosure-body")
|
|
22
|
+
], body)])), "@gjermundgaraba/pixel-paper/disclosure/disclosure.js#toView")
|
|
23
|
+
}, h)), "@gjermundgaraba/pixel-paper/disclosure/disclosure.js#view");
|
|
24
|
+
};
|
|
25
|
+
export { view };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { view } from "./disclosure.js";
|
|
4
|
+
// src/disclosure/index.ts
|
|
5
|
+
var disclosure_exports = /* @__PURE__ */ __exportAll({ view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/disclosure/index.js#view") });
|
|
6
|
+
export { disclosure_exports, view };
|