@gjermundgaraba/pixel-paper 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +50 -2
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/announcer/announcer.d.ts +35 -0
- package/dist/announcer/announcer.js +121 -0
- package/dist/announcer/index.d.ts +5 -0
- package/dist/announcer/index.js +11 -0
- package/dist/attributes/attributes.d.ts +4 -0
- package/dist/banner/banner.d.ts +20 -0
- package/dist/banner/banner.js +18 -0
- package/dist/banner/index.d.ts +5 -0
- package/dist/banner/index.js +6 -0
- package/dist/bench/bench.d.ts +16 -0
- package/dist/bench/bench.js +12 -0
- package/dist/bench/index.d.ts +5 -0
- package/dist/bench/index.js +6 -0
- package/dist/board/board.d.ts +1151 -0
- package/dist/board/board.js +449 -0
- package/dist/board/index.d.ts +6 -0
- package/dist/board/index.js +21 -0
- package/dist/button/button.d.ts +54 -0
- package/dist/button/button.js +50 -0
- package/dist/button/index.d.ts +5 -0
- package/dist/button/index.js +9 -0
- package/dist/card/card.d.ts +66 -0
- package/dist/card/card.js +70 -0
- package/dist/card/index.d.ts +5 -0
- package/dist/card/index.js +10 -0
- package/dist/chip/chip.d.ts +27 -0
- package/dist/chip/chip.js +34 -0
- package/dist/chip/index.d.ts +5 -0
- package/dist/chip/index.js +9 -0
- package/dist/choice/choice.d.ts +16 -0
- package/dist/choice/choice.js +17 -0
- package/dist/choice/index.d.ts +5 -0
- package/dist/choice/index.js +6 -0
- package/dist/code-editor/code-editor.d.ts +15 -0
- package/dist/code-editor/code-editor.js +22 -0
- package/dist/code-editor/index.d.ts +5 -0
- package/dist/code-editor/index.js +6 -0
- package/dist/code-surface/code-surface.d.ts +12 -0
- package/dist/code-surface/code-surface.js +12 -0
- package/dist/code-surface/index.d.ts +5 -0
- package/dist/code-surface/index.js +6 -0
- package/dist/command-palette/command-palette.d.ts +579 -0
- package/dist/command-palette/command-palette.js +600 -0
- package/dist/command-palette/index.d.ts +9 -0
- package/dist/command-palette/index.js +32 -0
- package/dist/command-palette/keys.d.ts +13 -0
- package/dist/command-palette/keys.js +71 -0
- package/dist/command-palette/match.d.ts +43 -0
- package/dist/command-palette/match.js +45 -0
- package/dist/command-palette/message.d.ts +94 -0
- package/dist/command-palette/message.js +46 -0
- package/dist/confirm-dialog/confirm-dialog.d.ts +287 -0
- package/dist/confirm-dialog/confirm-dialog.js +115 -0
- package/dist/confirm-dialog/index.d.ts +5 -0
- package/dist/confirm-dialog/index.js +17 -0
- package/dist/copy-button/copy-button.d.ts +99 -0
- package/dist/copy-button/copy-button.js +96 -0
- package/dist/copy-button/index.d.ts +5 -0
- package/dist/copy-button/index.js +13 -0
- package/dist/crumbs/crumbs.d.ts +15 -0
- package/dist/crumbs/crumbs.js +11 -0
- package/dist/crumbs/index.d.ts +5 -0
- package/dist/crumbs/index.js +6 -0
- package/dist/deck/deck.d.ts +9 -0
- package/dist/deck/deck.js +9 -0
- package/dist/deck/index.d.ts +5 -0
- package/dist/deck/index.js +6 -0
- package/dist/dialog/dialog.d.ts +278 -0
- package/dist/dialog/dialog.js +145 -0
- package/dist/dialog/fold.d.ts +58 -0
- package/dist/dialog/fold.js +63 -0
- package/dist/dialog/index.d.ts +6 -0
- package/dist/dialog/index.js +21 -0
- package/dist/disclosure/disclosure.d.ts +24 -0
- package/dist/disclosure/disclosure.js +25 -0
- package/dist/disclosure/index.d.ts +5 -0
- package/dist/disclosure/index.js +6 -0
- package/dist/dom/html-element.js +8 -0
- package/dist/drag/drag.d.ts +15 -0
- package/dist/drag/drag.js +123 -0
- package/dist/drop-zone/drop-zone.d.ts +119 -0
- package/dist/drop-zone/drop-zone.js +64 -0
- package/dist/drop-zone/index.d.ts +5 -0
- package/dist/drop-zone/index.js +14 -0
- package/dist/empty-state/empty-state.d.ts +18 -0
- package/dist/empty-state/empty-state.js +16 -0
- package/dist/empty-state/index.d.ts +5 -0
- package/dist/empty-state/index.js +6 -0
- package/dist/error-summary/error-summary.d.ts +34 -0
- package/dist/error-summary/error-summary.js +33 -0
- package/dist/error-summary/index.d.ts +5 -0
- package/dist/error-summary/index.js +6 -0
- package/dist/field/field.d.ts +35 -0
- package/dist/field/field.js +34 -0
- package/dist/field/index.d.ts +5 -0
- package/dist/field/index.js +6 -0
- package/dist/field-grid/field-grid.d.ts +8 -0
- package/dist/field-grid/field-grid.js +8 -0
- package/dist/field-grid/index.d.ts +5 -0
- package/dist/field-grid/index.js +6 -0
- package/dist/fields/fields.js +9 -0
- package/dist/fieldset/fieldset.d.ts +13 -0
- package/dist/fieldset/fieldset.js +13 -0
- package/dist/fieldset/index.d.ts +5 -0
- package/dist/fieldset/index.js +6 -0
- package/dist/filter-chip/filter-chip.d.ts +21 -0
- package/dist/filter-chip/filter-chip.js +28 -0
- package/dist/filter-chip/index.d.ts +5 -0
- package/dist/filter-chip/index.js +6 -0
- package/dist/filter-strip/filter-strip.d.ts +12 -0
- package/dist/filter-strip/filter-strip.js +13 -0
- package/dist/filter-strip/index.d.ts +5 -0
- package/dist/filter-strip/index.js +6 -0
- package/dist/flash-word/flash-word.d.ts +31 -0
- package/dist/flash-word/flash-word.js +31 -0
- package/dist/flash-word/index.d.ts +5 -0
- package/dist/flash-word/index.js +9 -0
- package/dist/focus/focus.d.ts +15 -0
- package/dist/focus/focus.js +17 -0
- package/dist/focus/index.d.ts +5 -0
- package/dist/focus/index.js +9 -0
- package/dist/format/format.js +52 -0
- package/dist/format/index.d.ts +5 -0
- package/dist/format/index.js +6 -0
- package/dist/glyph/glyph.d.ts +9 -0
- package/dist/glyph/glyph.js +25 -0
- package/dist/glyph/glyphs.d.ts +381 -0
- package/dist/glyph/glyphs.js +2603 -0
- package/dist/glyph/index.d.ts +5 -0
- package/dist/glyph/index.js +6 -0
- package/dist/group/group.d.ts +8 -0
- package/dist/group/group.js +9 -0
- package/dist/group/index.d.ts +5 -0
- package/dist/group/index.js +6 -0
- package/dist/history/history.d.ts +34 -0
- package/dist/history/history.js +15 -0
- package/dist/history/index.d.ts +5 -0
- package/dist/history/index.js +6 -0
- package/dist/icon-button/icon-button.d.ts +23 -0
- package/dist/icon-button/icon-button.js +23 -0
- package/dist/icon-button/index.d.ts +5 -0
- package/dist/icon-button/index.js +6 -0
- package/dist/identity/identity.d.ts +15 -0
- package/dist/identity/identity.js +15 -0
- package/dist/identity/index.d.ts +5 -0
- package/dist/identity/index.js +6 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +85 -0
- package/dist/inline-input/index.d.ts +5 -0
- package/dist/inline-input/index.js +20 -0
- package/dist/inline-input/inline-input.d.ts +196 -0
- package/dist/inline-input/inline-input.js +212 -0
- package/dist/key-help/index.d.ts +5 -0
- package/dist/key-help/index.js +18 -0
- package/dist/key-help/key-help.d.ts +255 -0
- package/dist/key-help/key-help.js +137 -0
- package/dist/key-hint/index.d.ts +6 -0
- package/dist/key-hint/index.js +12 -0
- package/dist/key-hint/key-hint.d.ts +13 -0
- package/dist/key-hint/key-hint.js +7 -0
- package/dist/key-hint/key-label.d.ts +18 -0
- package/dist/key-hint/key-label.js +77 -0
- package/dist/keymap/keymap.d.ts +11 -0
- package/dist/keymap/keymap.js +9 -0
- package/dist/keys/keys.js +4 -0
- package/dist/line-diff/diff.d.ts +2 -0
- package/dist/line-diff/diff.js +73 -0
- package/dist/line-diff/index.d.ts +6 -0
- package/dist/line-diff/index.js +10 -0
- package/dist/line-diff/line-diff.d.ts +21 -0
- package/dist/line-diff/line-diff.js +75 -0
- package/dist/line-diff/patch.d.ts +15 -0
- package/dist/line-diff/patch.js +120 -0
- package/dist/link-button/index.d.ts +5 -0
- package/dist/link-button/index.js +6 -0
- package/dist/link-button/link-button.d.ts +11 -0
- package/dist/link-button/link-button.js +10 -0
- package/dist/link-state/index.d.ts +5 -0
- package/dist/link-state/index.js +6 -0
- package/dist/link-state/link-state.d.ts +15 -0
- package/dist/link-state/link-state.js +17 -0
- package/dist/live-region/index.d.ts +5 -0
- package/dist/live-region/index.js +9 -0
- package/dist/live-region/live-region.d.ts +39 -0
- package/dist/live-region/live-region.js +33 -0
- package/dist/loading/index.d.ts +5 -0
- package/dist/loading/index.js +6 -0
- package/dist/loading/loading.d.ts +19 -0
- package/dist/loading/loading.js +16 -0
- package/dist/locale/locale.d.ts +3 -0
- package/dist/locale/locale.js +5 -0
- package/dist/mark/index.d.ts +5 -0
- package/dist/mark/index.js +6 -0
- package/dist/mark/mark.d.ts +15 -0
- package/dist/mark/mark.js +30 -0
- package/dist/menu/index.d.ts +7 -0
- package/dist/menu/index.js +25 -0
- package/dist/menu/item.d.ts +236 -0
- package/dist/menu/item.js +19 -0
- package/dist/menu/menu.d.ts +206 -0
- package/dist/menu/menu.js +208 -0
- package/dist/menu/slip.js +163 -0
- package/dist/meter/index.d.ts +5 -0
- package/dist/meter/index.js +6 -0
- package/dist/meter/meter.d.ts +38 -0
- package/dist/meter/meter.js +69 -0
- package/dist/monogram/monogram.js +33 -0
- package/dist/nav-strip/index.d.ts +5 -0
- package/dist/nav-strip/index.js +6 -0
- package/dist/nav-strip/nav-strip.d.ts +19 -0
- package/dist/nav-strip/nav-strip.js +21 -0
- package/dist/notice/index.d.ts +5 -0
- package/dist/notice/index.js +6 -0
- package/dist/notice/notice.d.ts +23 -0
- package/dist/notice/notice.js +35 -0
- package/dist/outcome/index.d.ts +5 -0
- package/dist/outcome/index.js +6 -0
- package/dist/outcome/outcome.d.ts +19 -0
- package/dist/outcome/outcome.js +14 -0
- package/dist/page-head/index.d.ts +5 -0
- package/dist/page-head/index.js +6 -0
- package/dist/page-head/page-head.d.ts +13 -0
- package/dist/page-head/page-head.js +10 -0
- package/dist/panel/index.d.ts +5 -0
- package/dist/panel/index.js +6 -0
- package/dist/panel/panel.d.ts +35 -0
- package/dist/panel/panel.js +25 -0
- package/dist/password-field/index.d.ts +5 -0
- package/dist/password-field/index.js +6 -0
- package/dist/password-field/password-field.d.ts +33 -0
- package/dist/password-field/password-field.js +39 -0
- package/dist/places/index.d.ts +5 -0
- package/dist/places/index.js +6 -0
- package/dist/places/places.d.ts +32 -0
- package/dist/places/places.js +22 -0
- package/dist/props-list/index.d.ts +5 -0
- package/dist/props-list/index.js +6 -0
- package/dist/props-list/props-list.d.ts +18 -0
- package/dist/props-list/props-list.js +12 -0
- package/dist/prose/index.d.ts +5 -0
- package/dist/prose/index.js +6 -0
- package/dist/prose/prose.d.ts +14 -0
- package/dist/prose/prose.js +6 -0
- package/dist/query-chip/index.d.ts +5 -0
- package/dist/query-chip/index.js +6 -0
- package/dist/query-chip/query-chip.d.ts +18 -0
- package/dist/query-chip/query-chip.js +17 -0
- package/dist/radio-choices/index.d.ts +5 -0
- package/dist/radio-choices/index.js +12 -0
- package/dist/radio-choices/radio-choices.d.ts +105 -0
- package/dist/radio-choices/radio-choices.js +56 -0
- package/dist/rail/index.d.ts +5 -0
- package/dist/rail/index.js +22 -0
- package/dist/rail/rail.d.ts +403 -0
- package/dist/rail/rail.js +355 -0
- package/dist/reel/index.d.ts +6 -0
- package/dist/reel/index.js +26 -0
- package/dist/reel/layout.d.ts +58 -0
- package/dist/reel/layout.js +378 -0
- package/dist/reel/reel.d.ts +1070 -0
- package/dist/reel/reel.js +1019 -0
- package/dist/remote/index.d.ts +5 -0
- package/dist/remote/index.js +6 -0
- package/dist/remote/remote.d.ts +28 -0
- package/dist/remote/remote.js +41 -0
- package/dist/rows/index.d.ts +5 -0
- package/dist/rows/index.js +12 -0
- package/dist/rows/rows.d.ts +116 -0
- package/dist/rows/rows.js +67 -0
- package/dist/scheme/index.d.ts +6 -0
- package/dist/scheme/index.js +10 -0
- package/dist/scheme/scheme-switch.d.ts +98 -0
- package/dist/scheme/scheme-switch.js +118 -0
- package/dist/scheme/scheme.d.ts +5 -0
- package/dist/scheme/scheme.js +16 -0
- package/dist/scheme/script.d.ts +8 -0
- package/dist/scheme/script.js +10 -0
- package/dist/secret/index.d.ts +5 -0
- package/dist/secret/index.js +6 -0
- package/dist/secret/secret.d.ts +13 -0
- package/dist/secret/secret.js +9 -0
- package/dist/segmented/index.d.ts +5 -0
- package/dist/segmented/index.js +6 -0
- package/dist/segmented/segmented.d.ts +17 -0
- package/dist/segmented/segmented.js +17 -0
- package/dist/select-field/index.d.ts +5 -0
- package/dist/select-field/index.js +6 -0
- package/dist/select-field/select-field.d.ts +38 -0
- package/dist/select-field/select-field.js +29 -0
- package/dist/sheet/index.d.ts +5 -0
- package/dist/sheet/index.js +6 -0
- package/dist/sheet/sheet.d.ts +16 -0
- package/dist/sheet/sheet.js +15 -0
- package/dist/skip-link/index.d.ts +5 -0
- package/dist/skip-link/index.js +9 -0
- package/dist/skip-link/skip-link.d.ts +23 -0
- package/dist/skip-link/skip-link.js +36 -0
- package/dist/slot/slot.js +8 -0
- package/dist/sortable/index.d.ts +5 -0
- package/dist/sortable/index.js +16 -0
- package/dist/sortable/sortable.d.ts +1125 -0
- package/dist/sortable/sortable.js +431 -0
- package/dist/stack/index.d.ts +5 -0
- package/dist/stack/index.js +6 -0
- package/dist/stack/stack.d.ts +15 -0
- package/dist/stack/stack.js +12 -0
- package/dist/stage/index.d.ts +5 -0
- package/dist/stage/index.js +6 -0
- package/dist/stage/stage.d.ts +14 -0
- package/dist/stage/stage.js +11 -0
- package/dist/stat/index.d.ts +5 -0
- package/dist/stat/index.js +6 -0
- package/dist/stat/stat.d.ts +18 -0
- package/dist/stat/stat.js +13 -0
- package/dist/status-bar/index.d.ts +6 -0
- package/dist/status-bar/index.js +11 -0
- package/dist/status-bar/status-bar.d.ts +28 -0
- package/dist/status-bar/status-bar.js +19 -0
- package/dist/subscription/prefix-keys.js +12 -0
- package/dist/table/index.d.ts +5 -0
- package/dist/table/index.js +6 -0
- package/dist/table/table.d.ts +26 -0
- package/dist/table/table.js +18 -0
- package/dist/tabs/index.d.ts +5 -0
- package/dist/tabs/index.js +14 -0
- package/dist/tabs/tabs.d.ts +125 -0
- package/dist/tabs/tabs.js +57 -0
- package/dist/tag/index.d.ts +5 -0
- package/dist/tag/index.js +6 -0
- package/dist/tag/tag.d.ts +16 -0
- package/dist/tag/tag.js +25 -0
- package/dist/text-button/index.d.ts +5 -0
- package/dist/text-button/index.js +6 -0
- package/dist/text-button/text-button.d.ts +8 -0
- package/dist/text-button/text-button.js +12 -0
- package/dist/textarea-field/index.d.ts +5 -0
- package/dist/textarea-field/index.js +6 -0
- package/dist/textarea-field/textarea-field.d.ts +28 -0
- package/dist/textarea-field/textarea-field.js +30 -0
- package/dist/time/index.d.ts +5 -0
- package/dist/time/index.js +9 -0
- package/dist/time/time.d.ts +38 -0
- package/dist/time/time.js +63 -0
- package/dist/tips/index.d.ts +5 -0
- package/dist/tips/index.js +14 -0
- package/dist/tips/tips.d.ts +339 -0
- package/dist/tips/tips.js +308 -0
- package/dist/toast/index.d.ts +5 -0
- package/dist/toast/index.js +17 -0
- package/dist/toast/stack.d.ts +7 -0
- package/dist/toast/stack.js +23 -0
- package/dist/toast/toast.d.ts +559 -0
- package/dist/toast/toast.js +269 -0
- package/dist/toc/index.d.ts +5 -0
- package/dist/toc/index.js +9 -0
- package/dist/toc/toc.d.ts +42 -0
- package/dist/toc/toc.js +35 -0
- package/dist/top-bar/bar-height.d.ts +26 -0
- package/dist/top-bar/bar-height.js +43 -0
- package/dist/top-bar/index.d.ts +6 -0
- package/dist/top-bar/index.js +12 -0
- package/dist/top-bar/top-bar.d.ts +19 -0
- package/dist/top-bar/top-bar.js +18 -0
- package/dist/wall/index.d.ts +5 -0
- package/dist/wall/index.js +9 -0
- package/dist/wall/wall.d.ts +16 -0
- package/dist/wall/wall.js +15 -0
- package/dist/window/index.d.ts +5 -0
- package/dist/window/index.js +6 -0
- package/dist/window/window.d.ts +28 -0
- package/dist/window/window.js +29 -0
- package/dist/wordmark/index.d.ts +5 -0
- package/dist/wordmark/index.js +6 -0
- package/dist/wordmark/wordmark.d.ts +10 -0
- package/dist/wordmark/wordmark.js +10 -0
- package/dist/wrap/index.d.ts +5 -0
- package/dist/wrap/index.js +6 -0
- package/dist/wrap/wrap.d.ts +12 -0
- package/dist/wrap/wrap.js +9 -0
- package/fonts/DepartureMono-Regular.woff2 +0 -0
- package/fonts/LICENSE.txt +2 -0
- package/package.json +57 -3
- package/src/pixel-paper.css +4611 -0
- package/src/tokens.css +151 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { view } from "../key-hint/key-hint.js";
|
|
3
|
+
import { isPlain } from "../keys/keys.js";
|
|
4
|
+
import { Item } from "./item.js";
|
|
5
|
+
import { Array, Effect, Match, Option, Queue, Schema, Stream, String, pipe } from "effect";
|
|
6
|
+
import { Anchor, Button } from "@foldkit/ui";
|
|
7
|
+
// src/menu/slip.ts
|
|
8
|
+
const ChoiceKind = Schema.Literals([
|
|
9
|
+
"Action",
|
|
10
|
+
"Radio",
|
|
11
|
+
"Check",
|
|
12
|
+
"Link"
|
|
13
|
+
]);
|
|
14
|
+
const ITEM_SELECTOR = "[role^=\"menuitem\"]";
|
|
15
|
+
const FIRST_ATTRIBUTE = "data-pixel-paper-slip-first";
|
|
16
|
+
const LAST_ATTRIBUTE = "data-pixel-paper-slip-last";
|
|
17
|
+
/** Where focus lands as the slip opens: its first row, or (↑ on the toggle) its last. */
|
|
18
|
+
const Edge = Schema.Literals(["First", "Last"]);
|
|
19
|
+
const edgeSelector = (edge) => __foldkitBrandViewResult((edge === "First" ? `[${FIRST_ATTRIBUTE}]` : `[${LAST_ATTRIBUTE}]`), "@gjermundgaraba/pixel-paper/menu/slip.js#edgeSelector");
|
|
20
|
+
const isGroup = Item.$is("Group");
|
|
21
|
+
const entriesOf = (items) => __foldkitBrandViewResult((Array.flatMap(items, (item) => __foldkitBrandViewResult((isGroup(item) ? item.items : [item]), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous"))), "@gjermundgaraba/pixel-paper/menu/slip.js#entriesOf");
|
|
22
|
+
const entryIds = (items) => __foldkitBrandViewResult((Array.map(entriesOf(items), (entry) => __foldkitBrandViewResult((entry.id), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~2"))), "@gjermundgaraba/pixel-paper/menu/slip.js#entryIds");
|
|
23
|
+
const edgeAttributes = (context, id, h) => __foldkitBrandViewResult(([...Option.contains(context.firstId, id) ? [h.Attribute(FIRST_ATTRIBUTE, "")] : [], ...Option.contains(context.lastId, id) ? [h.Attribute(LAST_ATTRIBUTE, "")] : []]), "@gjermundgaraba/pixel-paper/menu/slip.js#edgeAttributes");
|
|
24
|
+
const wordsView = (entry, h) => __foldkitBrandViewResult(([h.span([h.Class("menu-label")], [entry.label]), ...entry.keyHint === void 0 ? [] : [view(entry.keyHint, h)]]), "@gjermundgaraba/pixel-paper/menu/slip.js#wordsView");
|
|
25
|
+
const buttonRowView = (config, context, h) => {
|
|
26
|
+
const { entry, isDisabled, attributes, children } = config;
|
|
27
|
+
return __foldkitBrandViewResult((Button.view({
|
|
28
|
+
onClick: context.toChoose(entry.id, entry._tag),
|
|
29
|
+
isDisabled,
|
|
30
|
+
toView: (groups) => __foldkitBrandViewResult((h.keyed("button")(entry.id, [
|
|
31
|
+
...groups.button,
|
|
32
|
+
...attributes,
|
|
33
|
+
h.Tabindex(-1),
|
|
34
|
+
...edgeAttributes(context, entry.id, h)
|
|
35
|
+
], children)), "@gjermundgaraba/pixel-paper/menu/slip.js#toView")
|
|
36
|
+
}, h)), "@gjermundgaraba/pixel-paper/menu/slip.js#buttonRowView");
|
|
37
|
+
};
|
|
38
|
+
const entryView = (entry, context, h) => __foldkitBrandViewResult((Match.value(entry).pipe(Match.withReturnType(), Match.tag("Action", (action) => __foldkitBrandViewResult((buttonRowView({
|
|
39
|
+
entry: action,
|
|
40
|
+
isDisabled: action.isDisabled === true,
|
|
41
|
+
attributes: [h.Role("menuitem")],
|
|
42
|
+
children: wordsView(action, h)
|
|
43
|
+
}, context, h)), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~3")), Match.tag("Radio", (radio) => __foldkitBrandViewResult((buttonRowView({
|
|
44
|
+
entry: radio,
|
|
45
|
+
isDisabled: false,
|
|
46
|
+
attributes: [h.Role("menuitemradio"), h.AriaChecked(radio.isChecked)],
|
|
47
|
+
children: wordsView(radio, h)
|
|
48
|
+
}, context, h)), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~4")), Match.tag("Check", (check) => __foldkitBrandViewResult((buttonRowView({
|
|
49
|
+
entry: check,
|
|
50
|
+
isDisabled: false,
|
|
51
|
+
attributes: [h.Role("menuitemcheckbox"), h.AriaChecked(check.isChecked)],
|
|
52
|
+
children: [h.span([h.Class("menu-check"), h.AriaHidden(true)]), h.span([h.Class("menu-label")], [check.label])]
|
|
53
|
+
}, context, h)), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~5")), Match.tag("Link", (link) => __foldkitBrandViewResult((h.keyed("a")(link.id, [
|
|
54
|
+
h.Role("menuitem"),
|
|
55
|
+
h.Href(link.href),
|
|
56
|
+
h.Tabindex(-1),
|
|
57
|
+
h.OnClick(context.toChoose(link.id, link._tag)),
|
|
58
|
+
...edgeAttributes(context, link.id, h)
|
|
59
|
+
], wordsView(link, h))), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~6")), Match.exhaustive)), "@gjermundgaraba/pixel-paper/menu/slip.js#entryView");
|
|
60
|
+
const rowsView = (config, h) => {
|
|
61
|
+
const ids = entryIds(config.items);
|
|
62
|
+
const context = {
|
|
63
|
+
firstId: Array.head(ids),
|
|
64
|
+
lastId: Array.last(ids),
|
|
65
|
+
toChoose: config.toChoose
|
|
66
|
+
};
|
|
67
|
+
return __foldkitBrandViewResult((Array.map(config.items, (item, index) => {
|
|
68
|
+
if (!isGroup(item)) return __foldkitBrandViewResult((entryView(item, context, h)), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~7");
|
|
69
|
+
const headingId = `${config.slipId}-group-${index}`;
|
|
70
|
+
return __foldkitBrandViewResult((h.keyed("div")(`group:${item.label}`, [h.Role("group"), h.AriaLabelledBy(headingId)], [h.span([
|
|
71
|
+
h.Id(headingId),
|
|
72
|
+
h.Class("menu-note"),
|
|
73
|
+
h.Role("none")
|
|
74
|
+
], [item.label]), ...Array.map(item.items, (entry) => __foldkitBrandViewResult((entryView(entry, context, h)), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~8"))])), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~7");
|
|
75
|
+
})), "@gjermundgaraba/pixel-paper/menu/slip.js#rowsView");
|
|
76
|
+
};
|
|
77
|
+
const itemsOf = (slip) => __foldkitBrandViewResult((Array.fromIterable(slip.querySelectorAll(ITEM_SELECTOR))), "@gjermundgaraba/pixel-paper/menu/slip.js#itemsOf");
|
|
78
|
+
const focusedIndex = (items) => __foldkitBrandViewResult((Array.findFirstIndex(items, (item) => __foldkitBrandViewResult((item === document.activeElement), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~9"))), "@gjermundgaraba/pixel-paper/menu/slip.js#focusedIndex");
|
|
79
|
+
const focusAt = (items, index) => __foldkitBrandViewResult((Option.match(Array.get(items, index), {
|
|
80
|
+
onNone: () => __foldkitBrandViewResult((false), "@gjermundgaraba/pixel-paper/menu/slip.js#onNone"),
|
|
81
|
+
onSome: (item) => {
|
|
82
|
+
item.focus();
|
|
83
|
+
return __foldkitBrandViewResult((true), "@gjermundgaraba/pixel-paper/menu/slip.js#onSome");
|
|
84
|
+
}
|
|
85
|
+
})), "@gjermundgaraba/pixel-paper/menu/slip.js#focusAt");
|
|
86
|
+
const wrap = (index, length) => __foldkitBrandViewResult(((index + length) % length), "@gjermundgaraba/pixel-paper/menu/slip.js#wrap");
|
|
87
|
+
const startsWith = (item, key) => __foldkitBrandViewResult((pipe(item.textContent ?? "", String.trim, String.toLowerCase, String.startsWith(String.toLowerCase(key)))), "@gjermundgaraba/pixel-paper/menu/slip.js#startsWith");
|
|
88
|
+
const typeahead = (items, key) => {
|
|
89
|
+
const from = Option.getOrElse(focusedIndex(items), () => __foldkitBrandViewResult((-1), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~10"));
|
|
90
|
+
const ordered = [...Array.drop(items, from + 1), ...Array.take(items, from + 1)];
|
|
91
|
+
return __foldkitBrandViewResult((Option.match(Array.findFirst(ordered, (item) => __foldkitBrandViewResult((startsWith(item, key)), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~11")), {
|
|
92
|
+
onNone: () => __foldkitBrandViewResult((false), "@gjermundgaraba/pixel-paper/menu/slip.js#onNone~2"),
|
|
93
|
+
onSome: (item) => {
|
|
94
|
+
item.focus();
|
|
95
|
+
return __foldkitBrandViewResult((true), "@gjermundgaraba/pixel-paper/menu/slip.js#onSome~2");
|
|
96
|
+
}
|
|
97
|
+
})), "@gjermundgaraba/pixel-paper/menu/slip.js#typeahead");
|
|
98
|
+
};
|
|
99
|
+
const isShiftTab = (event) => __foldkitBrandViewResult((event.key === "Tab" && event.shiftKey && !event.altKey && !event.ctrlKey && !event.metaKey), "@gjermundgaraba/pixel-paper/menu/slip.js#isShiftTab");
|
|
100
|
+
const handleSlipKey = (slip, event, events) => {
|
|
101
|
+
if (event.isComposing || event.defaultPrevented || !(isPlain(event) || isShiftTab(event))) return __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/menu/slip.js#handleSlipKey");
|
|
102
|
+
const items = itemsOf(slip);
|
|
103
|
+
const { length } = items;
|
|
104
|
+
const current = Option.getOrElse(focusedIndex(items), () => __foldkitBrandViewResult((-1), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~12"));
|
|
105
|
+
const moved = (didMove) => {
|
|
106
|
+
if (didMove) event.preventDefault();
|
|
107
|
+
return __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/menu/slip.js#moved");
|
|
108
|
+
};
|
|
109
|
+
const reported = (message) => {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
return __foldkitBrandViewResult((Option.some(message)), "@gjermundgaraba/pixel-paper/menu/slip.js#reported");
|
|
112
|
+
};
|
|
113
|
+
return __foldkitBrandViewResult((Match.value(event.key).pipe(Match.withReturnType(), Match.when("ArrowDown", () => __foldkitBrandViewResult((moved(length > 0 && focusAt(items, wrap(current + 1, length)))), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~13")), Match.when("ArrowUp", () => __foldkitBrandViewResult((moved(length > 0 && focusAt(items, wrap(Math.max(current, 0) - 1, length)))), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~14")), Match.when("Home", () => __foldkitBrandViewResult((moved(focusAt(items, 0))), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~15")), Match.when("End", () => __foldkitBrandViewResult((moved(focusAt(items, length - 1))), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~16")), Match.when("Escape", () => __foldkitBrandViewResult((reported(events.escape)), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~17")), Match.when("Tab", () => __foldkitBrandViewResult((reported(events.tab)), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~18")), Match.when((key) => __foldkitBrandViewResult((key.length === 1 && key !== " "), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~19"), (key) => __foldkitBrandViewResult((moved(typeahead(items, key))), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~20")), Match.orElse(() => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~21")))), "@gjermundgaraba/pixel-paper/menu/slip.js#handleSlipKey");
|
|
114
|
+
};
|
|
115
|
+
const isLeaving = (slip, next, keepId) => __foldkitBrandViewResult((!(next instanceof Node && slip.contains(next)) && !(next instanceof Element && Option.contains(keepId, next.id))), "@gjermundgaraba/pixel-paper/menu/slip.js#isLeaving");
|
|
116
|
+
const preventMouseDown = (event) => {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
};
|
|
119
|
+
/** The slip's keys and focus as a stream of its owner's Messages, set up by `setup` (anchoring,
|
|
120
|
+
* portaling) and torn down with the element. A press inside the slip keeps focus where it
|
|
121
|
+
* is, so a click on a row reaches it in every browser. */
|
|
122
|
+
const slipStream = (element, config) => __foldkitBrandViewResult((Stream.callback((queue) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
123
|
+
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
124
|
+
const cleanup = config.setup(element);
|
|
125
|
+
const onKeyDown = (event) => {
|
|
126
|
+
if (!(event instanceof KeyboardEvent)) return;
|
|
127
|
+
const maybeMessage = handleSlipKey(element, event, config.events);
|
|
128
|
+
if (Option.isSome(maybeMessage)) Queue.offerUnsafe(queue, maybeMessage.value);
|
|
129
|
+
};
|
|
130
|
+
const onFocusOut = (event) => {
|
|
131
|
+
if (event instanceof FocusEvent && isLeaving(element, event.relatedTarget, config.keepId)) Queue.offerUnsafe(queue, config.events.left);
|
|
132
|
+
};
|
|
133
|
+
element.addEventListener("keydown", onKeyDown);
|
|
134
|
+
element.addEventListener("focusout", onFocusOut);
|
|
135
|
+
element.addEventListener("mousedown", preventMouseDown);
|
|
136
|
+
return __foldkitBrandViewResult((() => {
|
|
137
|
+
element.removeEventListener("keydown", onKeyDown);
|
|
138
|
+
element.removeEventListener("focusout", onFocusOut);
|
|
139
|
+
element.removeEventListener("mousedown", preventMouseDown);
|
|
140
|
+
cleanup();
|
|
141
|
+
}), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~24");
|
|
142
|
+
}), (teardown) => __foldkitBrandViewResult((Effect.sync(teardown)), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~26"));
|
|
143
|
+
Queue.offerUnsafe(queue, config.placed);
|
|
144
|
+
return __foldkitBrandViewResult((yield* Effect.never), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~23");
|
|
145
|
+
})), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~22"))), "@gjermundgaraba/pixel-paper/menu/slip.js#slipStream");
|
|
146
|
+
const GAP = 6;
|
|
147
|
+
const WINDOW_PADDING = 12;
|
|
148
|
+
const anchorUnder = (config) => __foldkitBrandViewResult(((element) => __foldkitBrandViewResult((Anchor.anchorSetup(element, {
|
|
149
|
+
buttonId: config.toggleId,
|
|
150
|
+
anchor: {
|
|
151
|
+
placement: config.isEnd ? "bottom-end" : "bottom-start",
|
|
152
|
+
gap: GAP,
|
|
153
|
+
padding: WINDOW_PADDING
|
|
154
|
+
},
|
|
155
|
+
interceptTab: false,
|
|
156
|
+
focusAfterPosition: true,
|
|
157
|
+
focusSelector: edgeSelector(config.edge)
|
|
158
|
+
})), "@gjermundgaraba/pixel-paper/menu/slip.js#anonymous~27")), "@gjermundgaraba/pixel-paper/menu/slip.js#anchorUnder");
|
|
159
|
+
Schema.Struct({
|
|
160
|
+
x: Schema.Finite,
|
|
161
|
+
y: Schema.Finite
|
|
162
|
+
});
|
|
163
|
+
export { ChoiceKind, Edge, anchorUnder, edgeSelector, rowsView, slipStream };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { listView } from "./meter.js";
|
|
4
|
+
// src/meter/index.ts
|
|
5
|
+
var meter_exports = /* @__PURE__ */ __exportAll({ listView: () => __foldkitBrandViewResult((listView), "@gjermundgaraba/pixel-paper/meter/index.js#listView") });
|
|
6
|
+
export { listView, meter_exports };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
/** One meter in a `listView`. */
|
|
3
|
+
export type MeterConfig = Readonly<{
|
|
4
|
+
/** Unique in the document; names the meter's parts. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** What is measured; it names the meter. */
|
|
7
|
+
label: string;
|
|
8
|
+
value: number;
|
|
9
|
+
max: number;
|
|
10
|
+
/** Replaces the printed numbers and what screen readers hear:
|
|
11
|
+
* `"41,200 of 50,000 requests"`. */
|
|
12
|
+
valueText?: string;
|
|
13
|
+
/** Prints the numbers line (the default). Leave it out where it would repeat the
|
|
14
|
+
* percentage (`valueText: "62% used"`); screen readers still hear `valueText`. */
|
|
15
|
+
hasNumbers?: boolean;
|
|
16
|
+
/** The lit cells take the reading's tone as well: amber from 80%, red at `max`. For a page
|
|
17
|
+
* of readings scanned for their level, such as a wall of limits; the reading beside the
|
|
18
|
+
* cells still says it in a mark or a chip. */
|
|
19
|
+
isToned?: boolean;
|
|
20
|
+
/** The last reading failed: the cells print muted, the numbers are the last known, and
|
|
21
|
+
* screen readers hear "(stale)" after the name. Say why, and when it was last read, in
|
|
22
|
+
* `foot`. */
|
|
23
|
+
isStale?: boolean;
|
|
24
|
+
/** The foot line: when it resets, when it was read. */
|
|
25
|
+
foot?: ReadonlyArray<Html | string>;
|
|
26
|
+
}>;
|
|
27
|
+
/** Configuration for rendering a list of meters with `listView`. */
|
|
28
|
+
export type ListViewConfig = Readonly<{
|
|
29
|
+
meters: readonly MeterConfig[];
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* A ruled list of meters, edge to edge in a flush panel. Each is a named reading against a
|
|
33
|
+
* maximum, in the vocabulary of `<meter>`, built on `@foldkit/ui`'s Meter: 20 cells, the
|
|
34
|
+
* percentage (amber from 80%, a red chip at `max`, and neither 100% nor every cell before it),
|
|
35
|
+
* the numbers in English, a foot line. The cells print ink unless the meter `isToned`. The cells are the `meter`, named by the printed label,
|
|
36
|
+
* with the value, the maximum and the numbers in words for screen readers.
|
|
37
|
+
*/
|
|
38
|
+
export declare const listView: <Message>(config: ListViewConfig, h: HtmlBuilder<Message>) => Html;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { LOCALE } from "../locale/locale.js";
|
|
3
|
+
import { slotView } from "../slot/slot.js";
|
|
4
|
+
import { view } from "../chip/chip.js";
|
|
5
|
+
import { readingView } from "../mark/mark.js";
|
|
6
|
+
import { Array } from "effect";
|
|
7
|
+
import { Meter } from "@foldkit/ui";
|
|
8
|
+
// src/meter/meter.ts
|
|
9
|
+
const METER_CELLS = 20;
|
|
10
|
+
const HIGH_SHARE = .8;
|
|
11
|
+
const PERCENT = 100;
|
|
12
|
+
const cellRowView = (count, on, h) => __foldkitBrandViewResult((Array.makeBy(count, (index) => __foldkitBrandViewResult((h.span([h.Class(index < on ? "cell on" : "cell")])), "@gjermundgaraba/pixel-paper/meter/meter.js#anonymous"))), "@gjermundgaraba/pixel-paper/meter/meter.js#cellRowView");
|
|
13
|
+
const scaled = (share, whole, isFull) => {
|
|
14
|
+
const rounded = Math.round(share * whole);
|
|
15
|
+
return __foldkitBrandViewResult((isFull ? rounded : Math.min(whole - 1, rounded)), "@gjermundgaraba/pixel-paper/meter/meter.js#scaled");
|
|
16
|
+
};
|
|
17
|
+
const numbersText = (value, max) => __foldkitBrandViewResult((`${value.toLocaleString(LOCALE)} / ${max.toLocaleString(LOCALE)}`), "@gjermundgaraba/pixel-paper/meter/meter.js#numbersText");
|
|
18
|
+
const levelOf = (value, max) => {
|
|
19
|
+
if (value >= max) return __foldkitBrandViewResult(("Full"), "@gjermundgaraba/pixel-paper/meter/meter.js#levelOf");
|
|
20
|
+
else if (value >= max * HIGH_SHARE) return __foldkitBrandViewResult(("High"), "@gjermundgaraba/pixel-paper/meter/meter.js#levelOf");
|
|
21
|
+
return __foldkitBrandViewResult(("Calm"), "@gjermundgaraba/pixel-paper/meter/meter.js#levelOf");
|
|
22
|
+
};
|
|
23
|
+
const percentView = (percent, level, h) => {
|
|
24
|
+
const percentText = `${percent}%`;
|
|
25
|
+
if (level === "Full") return __foldkitBrandViewResult((view({
|
|
26
|
+
label: percentText,
|
|
27
|
+
tone: "Blocked"
|
|
28
|
+
}, h)), "@gjermundgaraba/pixel-paper/meter/meter.js#percentView");
|
|
29
|
+
else if (level === "High") return __foldkitBrandViewResult((readingView({ label: percentText }, h)), "@gjermundgaraba/pixel-paper/meter/meter.js#percentView");
|
|
30
|
+
return __foldkitBrandViewResult((h.span([h.Class("pct")], [percentText])), "@gjermundgaraba/pixel-paper/meter/meter.js#percentView");
|
|
31
|
+
};
|
|
32
|
+
const TONE_CLASS = {
|
|
33
|
+
Full: " toned full",
|
|
34
|
+
High: " toned high",
|
|
35
|
+
Calm: " toned"
|
|
36
|
+
};
|
|
37
|
+
const meterView = (config, h) => {
|
|
38
|
+
const { id, label, value, max, foot = [], isStale = false, hasNumbers = true, isToned = false } = config;
|
|
39
|
+
const share = max > 0 ? Math.min(1, Math.max(0, value / max)) : 0;
|
|
40
|
+
const level = levelOf(value, max);
|
|
41
|
+
const isFull = level === "Full";
|
|
42
|
+
const numbers = config.valueText ?? numbersText(value, max);
|
|
43
|
+
const rowClass = `meter-row${isStale ? " stale" : ""}${isToned ? TONE_CLASS[level] : ""}`;
|
|
44
|
+
return __foldkitBrandViewResult((Meter.view({
|
|
45
|
+
id,
|
|
46
|
+
value,
|
|
47
|
+
min: 0,
|
|
48
|
+
max,
|
|
49
|
+
valueText: numbers,
|
|
50
|
+
toView: (groups) => __foldkitBrandViewResult((h.keyed("li")(id, [h.Class(rowClass)], [
|
|
51
|
+
h.div([h.Class("meter-head")], [h.span([...groups.label, h.Class("meter-name")], [label, ...isStale ? [h.span([h.Class("sr-only")], [" (stale)"])] : []])]),
|
|
52
|
+
h.div([h.Class("meter-line")], [
|
|
53
|
+
h.span([...groups.meter, h.Class("cells")], cellRowView(METER_CELLS, scaled(share, METER_CELLS, isFull), h)),
|
|
54
|
+
percentView(scaled(share, PERCENT, isFull), level, h),
|
|
55
|
+
...hasNumbers ? [h.span([h.Class("meter-num tnum")], [numbers])] : []
|
|
56
|
+
]),
|
|
57
|
+
...slotView("div", "meter-foot", foot, h)
|
|
58
|
+
])), "@gjermundgaraba/pixel-paper/meter/meter.js#toView")
|
|
59
|
+
}, h)), "@gjermundgaraba/pixel-paper/meter/meter.js#meterView");
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A ruled list of meters, edge to edge in a flush panel. Each is a named reading against a
|
|
63
|
+
* maximum, in the vocabulary of `<meter>`, built on `@foldkit/ui`'s Meter: 20 cells, the
|
|
64
|
+
* percentage (amber from 80%, a red chip at `max`, and neither 100% nor every cell before it),
|
|
65
|
+
* the numbers in English, a foot line. The cells print ink unless the meter `isToned`. The cells are the `meter`, named by the printed label,
|
|
66
|
+
* with the value, the maximum and the numbers in words for screen readers.
|
|
67
|
+
*/
|
|
68
|
+
const listView = (config, h) => __foldkitBrandViewResult((h.ul([h.Role("list"), h.Class("meters")], Array.map(config.meters, (meter) => __foldkitBrandViewResult((meterView(meter, h)), "@gjermundgaraba/pixel-paper/meter/meter.js#anonymous~2")))), "@gjermundgaraba/pixel-paper/meter/meter.js#listView");
|
|
69
|
+
export { listView };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { artRows, toCells } from "../glyph/glyphs.js";
|
|
3
|
+
import { cellView } from "../glyph/glyph.js";
|
|
4
|
+
import { Array, Number, String, pipe } from "effect";
|
|
5
|
+
// src/monogram/monogram.ts
|
|
6
|
+
const WORD_BREAK = /[\s._-]+/u;
|
|
7
|
+
const LETTER_COUNT = 2;
|
|
8
|
+
const initials = (name) => __foldkitBrandViewResult((pipe(name.split(WORD_BREAK), Array.filter(String.isNonEmpty), Array.match({
|
|
9
|
+
onEmpty: () => __foldkitBrandViewResult((""), "@gjermundgaraba/pixel-paper/monogram/monogram.js#onEmpty"),
|
|
10
|
+
onNonEmpty: (words) => __foldkitBrandViewResult((words.length > 1 ? pipe(Array.take(words, LETTER_COUNT), Array.map((word) => __foldkitBrandViewResult((word.slice(0, 1)), "@gjermundgaraba/pixel-paper/monogram/monogram.js#anonymous")), Array.join("")) : Array.headNonEmpty(words).slice(0, LETTER_COUNT)), "@gjermundgaraba/pixel-paper/monogram/monogram.js#onNonEmpty")
|
|
11
|
+
}))), "@gjermundgaraba/pixel-paper/monogram/monogram.js#initials");
|
|
12
|
+
const DRAWN_CELL = 1;
|
|
13
|
+
const LARGE_DRAWN_CELL = 2;
|
|
14
|
+
const drawingView = (art, isLarge, h) => {
|
|
15
|
+
const rows = artRows(art);
|
|
16
|
+
const columns = Array.reduce(rows, 0, (widest, row) => __foldkitBrandViewResult((Number.max(widest, row.length)), "@gjermundgaraba/pixel-paper/monogram/monogram.js#anonymous~2"));
|
|
17
|
+
const cell = isLarge ? LARGE_DRAWN_CELL : DRAWN_CELL;
|
|
18
|
+
return __foldkitBrandViewResult((h.svg([
|
|
19
|
+
h.ViewBox(`0 0 ${columns} ${rows.length}`),
|
|
20
|
+
h.Width(`${columns * cell}`),
|
|
21
|
+
h.Height(`${rows.length * cell}`),
|
|
22
|
+
h.AriaHidden(true),
|
|
23
|
+
h.Class("px-icon")
|
|
24
|
+
], Array.map(toCells(art, columns), cellView(h)))), "@gjermundgaraba/pixel-paper/monogram/monogram.js#drawingView");
|
|
25
|
+
};
|
|
26
|
+
/** Letters in an ink square, or a mark the product draws in cells: the identity of a person,
|
|
27
|
+
* a provider or a source. It sits beside the same name in words (as in Identity), so it is
|
|
28
|
+
* hidden from screen readers, which read the name once, from the words. */
|
|
29
|
+
const view = (config, h) => {
|
|
30
|
+
const { label, drawing, isLarge = false } = config;
|
|
31
|
+
return __foldkitBrandViewResult((h.span([h.AriaHidden(true), h.Class(`monogram${drawing === void 0 ? "" : " drawn"}${isLarge ? " large" : ""}`)], [drawing === void 0 ? initials(label) : drawingView(drawing, isLarge, h)])), "@gjermundgaraba/pixel-paper/monogram/monogram.js#view");
|
|
32
|
+
};
|
|
33
|
+
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 "./nav-strip.js";
|
|
4
|
+
// src/nav-strip/index.ts
|
|
5
|
+
var nav_strip_exports = /* @__PURE__ */ __exportAll({ view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/nav-strip/index.js#view") });
|
|
6
|
+
export { nav_strip_exports, view };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
/** One segment of the strip: a link. */
|
|
3
|
+
export type NavItem = Readonly<{
|
|
4
|
+
href: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** A count on the head tint after the label. */
|
|
7
|
+
count?: number;
|
|
8
|
+
isCurrent?: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
/** Configuration for rendering a nav strip with `view`. */
|
|
11
|
+
export type ViewConfig = Readonly<{
|
|
12
|
+
/** Names the navigation for screen readers. */
|
|
13
|
+
label: string;
|
|
14
|
+
items: readonly NavItem[];
|
|
15
|
+
}>;
|
|
16
|
+
/** One ink-bordered strip of link segments, built on `@foldkit/ui`'s Nav: a navigation
|
|
17
|
+
* landmark named by its label, the current page `aria-current="page"` and printed inverted.
|
|
18
|
+
* Its links route through the application as every link does. */
|
|
19
|
+
export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { LOCALE } from "../locale/locale.js";
|
|
3
|
+
import { Array, Option } from "effect";
|
|
4
|
+
import { Nav } from "@foldkit/ui";
|
|
5
|
+
// src/nav-strip/nav-strip.ts
|
|
6
|
+
const countView = (count, h) => __foldkitBrandViewResult(([h.span([h.Class("sr-only")], [" "]), h.span([h.Class("navnum")], [count.toLocaleString(LOCALE)])]), "@gjermundgaraba/pixel-paper/nav-strip/nav-strip.js#countView");
|
|
7
|
+
const linkView = (info, { label, count }, h) => __foldkitBrandViewResult((h.keyed("a")(info.value, info.link, [label, ...count === void 0 ? [] : countView(count, h)])), "@gjermundgaraba/pixel-paper/nav-strip/nav-strip.js#linkView");
|
|
8
|
+
/** One ink-bordered strip of link segments, built on `@foldkit/ui`'s Nav: a navigation
|
|
9
|
+
* landmark named by its label, the current page `aria-current="page"` and printed inverted.
|
|
10
|
+
* Its links route through the application as every link does. */
|
|
11
|
+
const view = (config, h) => {
|
|
12
|
+
const { label, items } = config;
|
|
13
|
+
return __foldkitBrandViewResult((Nav.view({
|
|
14
|
+
items: Array.map(items, ({ href }) => __foldkitBrandViewResult((href), "@gjermundgaraba/pixel-paper/nav-strip/nav-strip.js#anonymous")),
|
|
15
|
+
ariaLabel: label,
|
|
16
|
+
toHref: (href) => __foldkitBrandViewResult((href), "@gjermundgaraba/pixel-paper/nav-strip/nav-strip.js#toHref"),
|
|
17
|
+
isItemCurrent: (_href, index) => __foldkitBrandViewResult((Option.exists(Array.get(items, index), ({ isCurrent = false }) => __foldkitBrandViewResult((isCurrent), "@gjermundgaraba/pixel-paper/nav-strip/nav-strip.js#anonymous~2"))), "@gjermundgaraba/pixel-paper/nav-strip/nav-strip.js#isItemCurrent"),
|
|
18
|
+
toView: (render) => __foldkitBrandViewResult((h.nav([...render.nav, h.Class("nav")], Array.zipWith(render.items, items, (info, item) => __foldkitBrandViewResult((linkView(info, item, h)), "@gjermundgaraba/pixel-paper/nav-strip/nav-strip.js#anonymous~3")))), "@gjermundgaraba/pixel-paper/nav-strip/nav-strip.js#toView")
|
|
19
|
+
})), "@gjermundgaraba/pixel-paper/nav-strip/nav-strip.js#view");
|
|
20
|
+
};
|
|
21
|
+
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 "./notice.js";
|
|
4
|
+
// src/notice/index.ts
|
|
5
|
+
var notice_exports = /* @__PURE__ */ __exportAll({ view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/notice/index.js#view") });
|
|
6
|
+
export { notice_exports, view };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Attributes } from "../attributes/attributes.js";
|
|
2
|
+
import { GlyphName } from "../glyph/glyphs.js";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
5
|
+
/** `Warn`: amber, a question or a stop. `Error`: red, refused or failed. `Ok`: a committed
|
|
6
|
+
* change, in ink. `Quiet`: tinted, nothing wrong. */
|
|
7
|
+
export declare const Tone: Schema.Literals<readonly ["Warn", "Error", "Ok", "Quiet"]>;
|
|
8
|
+
export type Tone = typeof Tone.Type;
|
|
9
|
+
/** Configuration for rendering a notice with `view`. */
|
|
10
|
+
export type ViewConfig<Message> = Readonly<{
|
|
11
|
+
tone?: Tone;
|
|
12
|
+
/** Pixel caps, on its own line. */
|
|
13
|
+
title?: string;
|
|
14
|
+
body: ReadonlyArray<Html | string>;
|
|
15
|
+
glyph?: GlyphName;
|
|
16
|
+
/** Controls at the right: retry, reconnect. */
|
|
17
|
+
actions?: ReadonlyArray<Html | string>;
|
|
18
|
+
/** Further attributes for the notice, never a class. */
|
|
19
|
+
attributes?: Attributes<Message>;
|
|
20
|
+
}>;
|
|
21
|
+
/** One line in the product's own words, beside a glyph in a box. An `Error` notice is an
|
|
22
|
+
* alert (`role="alert"`), so a screen reader says it when it appears; the others are quiet. */
|
|
23
|
+
export declare const view: <Message>(config: ViewConfig<Message>, h: HtmlBuilder<Message>) => Html;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { view as view$1 } from "../glyph/glyph.js";
|
|
3
|
+
import { Match, Schema } from "effect";
|
|
4
|
+
Schema.Literals([
|
|
5
|
+
"Warn",
|
|
6
|
+
"Error",
|
|
7
|
+
"Ok",
|
|
8
|
+
"Quiet"
|
|
9
|
+
]);
|
|
10
|
+
const toneGlyph = (tone) => __foldkitBrandViewResult((Match.value(tone).pipe(Match.withReturnType(), Match.whenOr("Warn", "Error", () => __foldkitBrandViewResult(("bang"), "@gjermundgaraba/pixel-paper/notice/notice.js#anonymous")), Match.when("Ok", () => __foldkitBrandViewResult(("check"), "@gjermundgaraba/pixel-paper/notice/notice.js#anonymous~2")), Match.when("Quiet", () => __foldkitBrandViewResult(("info"), "@gjermundgaraba/pixel-paper/notice/notice.js#anonymous~3")), Match.exhaustive)), "@gjermundgaraba/pixel-paper/notice/notice.js#toneGlyph");
|
|
11
|
+
const TONE_CLASS = {
|
|
12
|
+
Warn: "",
|
|
13
|
+
Error: " error",
|
|
14
|
+
Ok: " ok",
|
|
15
|
+
Quiet: " quiet"
|
|
16
|
+
};
|
|
17
|
+
const toneGlyphView = (config, h) => __foldkitBrandViewResult((h.span([h.Class(`glyph${TONE_CLASS[config.tone]}`)], [view$1({ name: config.glyph ?? toneGlyph(config.tone) }, h)])), "@gjermundgaraba/pixel-paper/notice/notice.js#toneGlyphView");
|
|
18
|
+
/** One line in the product's own words, beside a glyph in a box. An `Error` notice is an
|
|
19
|
+
* alert (`role="alert"`), so a screen reader says it when it appears; the others are quiet. */
|
|
20
|
+
const view = (config, h) => {
|
|
21
|
+
const { tone = "Warn", title, body, glyph, actions = [], attributes = [] } = config;
|
|
22
|
+
return __foldkitBrandViewResult((h.div([
|
|
23
|
+
...attributes,
|
|
24
|
+
...tone === "Error" ? [h.Role("alert")] : [],
|
|
25
|
+
h.Class(`notice${TONE_CLASS[tone]}`)
|
|
26
|
+
], [
|
|
27
|
+
toneGlyphView({
|
|
28
|
+
tone,
|
|
29
|
+
...glyph !== void 0 && { glyph }
|
|
30
|
+
}, h),
|
|
31
|
+
h.div([], [...title === void 0 ? [] : [h.strong([], [title])], ...body]),
|
|
32
|
+
...actions
|
|
33
|
+
])), "@gjermundgaraba/pixel-paper/notice/notice.js#view");
|
|
34
|
+
};
|
|
35
|
+
export { TONE_CLASS, toneGlyphView, 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 "./outcome.js";
|
|
4
|
+
// src/outcome/index.ts
|
|
5
|
+
var outcome_exports = /* @__PURE__ */ __exportAll({ view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/outcome/index.js#view") });
|
|
6
|
+
export { outcome_exports, view };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Attributes } from "../attributes/attributes.js";
|
|
2
|
+
import { Tone } from "../notice/notice.js";
|
|
3
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
4
|
+
/** Configuration for rendering an outcome with `view`. */
|
|
5
|
+
export type ViewConfig<Message> = Readonly<{
|
|
6
|
+
/** Pixel caps: what happened, or what is asked (`"Session ended"`). */
|
|
7
|
+
title: string;
|
|
8
|
+
/** One sans sentence: why, and what to do next. */
|
|
9
|
+
body: ReadonlyArray<Html | string>;
|
|
10
|
+
tone?: Tone;
|
|
11
|
+
/** What follows the sentence: a code, the details, a list of what was asked. */
|
|
12
|
+
detail?: ReadonlyArray<Html | string>;
|
|
13
|
+
/** Attributes for the title and sentence together, such as the `description` group of the
|
|
14
|
+
* dialog they describe; never a class. */
|
|
15
|
+
bodyAttributes?: Attributes<Message>;
|
|
16
|
+
}>;
|
|
17
|
+
/** A state said in full: a 34px glyph box, a title, a sentence. The body of a confirm, and of
|
|
18
|
+
* a wall that stops the reader (session ended, access refused, service away). */
|
|
19
|
+
export declare const view: <Message>(config: ViewConfig<Message>, h: HtmlBuilder<Message>) => Html;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { toneGlyphView } from "../notice/notice.js";
|
|
3
|
+
// src/outcome/outcome.ts
|
|
4
|
+
/** A state said in full: a 34px glyph box, a title, a sentence. The body of a confirm, and of
|
|
5
|
+
* a wall that stops the reader (session ended, access refused, service away). */
|
|
6
|
+
const view = (config, h) => {
|
|
7
|
+
const { title, body, tone = "Warn", detail = [], bodyAttributes = [] } = config;
|
|
8
|
+
return __foldkitBrandViewResult((h.div([h.Class("outcome")], [toneGlyphView({ tone }, h), h.div([...bodyAttributes, h.Class("outcome-body")], [
|
|
9
|
+
h.strong([], [title]),
|
|
10
|
+
h.p([], body),
|
|
11
|
+
...detail
|
|
12
|
+
])])), "@gjermundgaraba/pixel-paper/outcome/outcome.js#view");
|
|
13
|
+
};
|
|
14
|
+
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 "./page-head.js";
|
|
4
|
+
// src/page-head/index.ts
|
|
5
|
+
var page_head_exports = /* @__PURE__ */ __exportAll({ view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/page-head/index.js#view") });
|
|
6
|
+
export { page_head_exports, view };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
/** Configuration for rendering a page head with `view`. */
|
|
3
|
+
export type ViewConfig = Readonly<{
|
|
4
|
+
/** The screen's name: its `h1`, in sans. A long one wraps; nothing is cut. */
|
|
5
|
+
title: string;
|
|
6
|
+
/** A count or state after the title, in the pixel face ("12 items"). */
|
|
7
|
+
meta?: string;
|
|
8
|
+
/** The screen's own Buttons at the right; under the title on a phone. */
|
|
9
|
+
actions?: ReadonlyArray<Html | string>;
|
|
10
|
+
}>;
|
|
11
|
+
/** The heading of a working screen, above its panels: its name as the page's `h1`, a count
|
|
12
|
+
* beside it, and what the screen does. One per screen; the panels below it title in `h2`. */
|
|
13
|
+
export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { slotView } from "../slot/slot.js";
|
|
3
|
+
// src/page-head/page-head.ts
|
|
4
|
+
/** The heading of a working screen, above its panels: its name as the page's `h1`, a count
|
|
5
|
+
* beside it, and what the screen does. One per screen; the panels below it title in `h2`. */
|
|
6
|
+
const view = (config, h) => {
|
|
7
|
+
const { title, meta, actions = [] } = config;
|
|
8
|
+
return __foldkitBrandViewResult((h.div([h.Class("page-head")], [h.div([h.Class("page-name")], [h.h1([h.Class("page-title")], [title]), ...meta === void 0 ? [] : [h.span([h.Class("meta")], [meta])]]), ...slotView("div", "page-acts", actions, h)])), "@gjermundgaraba/pixel-paper/page-head/page-head.js#view");
|
|
9
|
+
};
|
|
10
|
+
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 "./panel.js";
|
|
4
|
+
// src/panel/index.ts
|
|
5
|
+
var panel_exports = /* @__PURE__ */ __exportAll({ view: () => __foldkitBrandViewResult((view), "@gjermundgaraba/pixel-paper/panel/index.js#view") });
|
|
6
|
+
export { panel_exports, view };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
/** Configuration for rendering a panel with `view`. */
|
|
3
|
+
export type ViewConfig = Readonly<{
|
|
4
|
+
/** Unique in the document: the title's id is made from it, and names the panel. It is the
|
|
5
|
+
* panel's key too, so a panel among siblings that come and go keeps its own element, and
|
|
6
|
+
* a panel with a different id is a different element: one that replaces another in the
|
|
7
|
+
* same place is built anew, live regions and all. To keep an element across states, render
|
|
8
|
+
* one panel under one id. */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Pixel caps in the inverted title bar. */
|
|
11
|
+
title: string;
|
|
12
|
+
/** What screen readers call the panel where its title repeats among its siblings (panels
|
|
13
|
+
* titled by a kind, one per account): the title and what tells this one apart. The
|
|
14
|
+
* title names it otherwise. */
|
|
15
|
+
name?: string;
|
|
16
|
+
/** A quiet IconButton before the title, such as the grip a Sortable of panels hands each
|
|
17
|
+
* panel. On the ink bar it prints as `actions` do. */
|
|
18
|
+
lead?: ReadonlyArray<Html | string>;
|
|
19
|
+
/** A count or state at the title bar's right. */
|
|
20
|
+
meta?: string;
|
|
21
|
+
/** Small Buttons and IconButtons at the title bar's right end, after the meta. On the ink
|
|
22
|
+
* bar they print in paper, flat, and ring in their own colour inside their edge. */
|
|
23
|
+
actions?: ReadonlyArray<Html | string>;
|
|
24
|
+
/** A strip on the head tint between the title bar and the body, for a field that picks what
|
|
25
|
+
* the body shows (an area over its tasks). Its labels print in on-head. */
|
|
26
|
+
shelf?: ReadonlyArray<Html | string>;
|
|
27
|
+
body: ReadonlyArray<Html | string>;
|
|
28
|
+
/** A ruled foot under the body: a note line, then actions pushed right. */
|
|
29
|
+
foot?: ReadonlyArray<Html | string>;
|
|
30
|
+
/** The body sits edge to edge (rows, tables, meters) instead of in the padded body. */
|
|
31
|
+
isFlush?: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
/** The unit of the system: paper in a 2px ink box on a 5px print shadow, under a title bar. A
|
|
34
|
+
* region landmark (`<section>`) named by its `h2` title, or by `name`, keyed by its `id`. */
|
|
35
|
+
export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
|