@gjermundgaraba-designs/pixel-paper 0.22.2 → 0.23.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/DESIGN.md +13 -13
- package/dist/src/adapters/mermaid.d.ts.map +1 -1
- package/dist/src/adapters/mermaid.js +0 -24
- package/dist/src/announcer/announcer.d.ts.map +1 -1
- package/dist/src/announcer/announcer.js +12 -12
- package/dist/src/board/board.d.ts +0 -10
- package/dist/src/board/board.d.ts.map +1 -1
- package/dist/src/board/board.js +36 -64
- package/dist/src/board/index.d.ts +2 -1
- package/dist/src/board/index.d.ts.map +1 -1
- package/dist/src/board/index.js +2 -1
- package/dist/src/button/button.d.ts +1 -1
- package/dist/src/button/button.d.ts.map +1 -1
- package/dist/src/commandPalette/commandPalette.d.ts.map +1 -1
- package/dist/src/commandPalette/commandPalette.js +78 -83
- package/dist/src/commandPalette/keys.d.ts +2 -2
- package/dist/src/commandPalette/keys.d.ts.map +1 -1
- package/dist/src/commandPalette/keys.js +2 -4
- package/dist/src/commandPalette/match.d.ts.map +1 -1
- package/dist/src/commandPalette/match.js +2 -2
- package/dist/src/confirmDialog/confirmDialog.d.ts.map +1 -1
- package/dist/src/confirmDialog/confirmDialog.js +1 -2
- package/dist/src/copyButton/copyButton.d.ts +0 -5
- package/dist/src/copyButton/copyButton.d.ts.map +1 -1
- package/dist/src/copyButton/copyButton.js +2 -2
- package/dist/src/crumbs/crumbs.d.ts +0 -2
- package/dist/src/crumbs/crumbs.d.ts.map +1 -1
- package/dist/src/crumbs/crumbs.js +2 -2
- package/dist/src/dialog/dialog.d.ts +2 -0
- package/dist/src/dialog/dialog.d.ts.map +1 -1
- package/dist/src/dialog/dialog.js +3 -2
- package/dist/src/drag/drag.d.ts +28 -0
- package/dist/src/drag/drag.d.ts.map +1 -1
- package/dist/src/drag/drag.js +39 -17
- package/dist/src/editableTitle/editableTitle.d.ts +4 -4
- package/dist/src/field/field.d.ts +7 -1
- package/dist/src/field/field.d.ts.map +1 -1
- package/dist/src/field/field.js +14 -6
- package/dist/src/fieldset/fieldset.d.ts.map +1 -1
- package/dist/src/fieldset/fieldset.js +2 -4
- package/dist/src/fileTree/fileTree.d.ts.map +1 -1
- package/dist/src/fileTree/fileTree.js +16 -16
- package/dist/src/inlineInput/inlineInput.d.ts +4 -0
- package/dist/src/inlineInput/inlineInput.d.ts.map +1 -1
- package/dist/src/inlineInput/inlineInput.js +9 -6
- package/dist/src/keyHelp/index.d.ts +1 -1
- package/dist/src/keyHelp/index.d.ts.map +1 -1
- package/dist/src/keyHelp/index.js +1 -1
- package/dist/src/keyHelp/keyHelp.d.ts +1 -3
- package/dist/src/keyHelp/keyHelp.d.ts.map +1 -1
- package/dist/src/keyHelp/keyHelp.js +3 -6
- package/dist/src/keyHint/keyLabel.d.ts +2 -0
- package/dist/src/keyHint/keyLabel.d.ts.map +1 -1
- package/dist/src/keyHint/keyLabel.js +3 -2
- package/dist/src/lineDiff/diff.d.ts +6 -3
- package/dist/src/lineDiff/diff.d.ts.map +1 -1
- package/dist/src/lineDiff/diff.js +40 -28
- package/dist/src/lineDiff/patch.d.ts.map +1 -1
- package/dist/src/lineDiff/patch.js +18 -13
- package/dist/src/linkState/linkState.d.ts.map +1 -1
- package/dist/src/linkState/linkState.js +1 -7
- package/dist/src/menu/slip.js +2 -2
- package/dist/src/meter/meter.d.ts.map +1 -1
- package/dist/src/meter/meter.js +22 -17
- package/dist/src/notice/notice.d.ts +2 -0
- package/dist/src/notice/notice.d.ts.map +1 -1
- package/dist/src/notice/notice.js +2 -1
- package/dist/src/passwordField/passwordField.d.ts.map +1 -1
- package/dist/src/passwordField/passwordField.js +3 -7
- package/dist/src/rail/rail.d.ts +17 -3
- package/dist/src/rail/rail.d.ts.map +1 -1
- package/dist/src/rail/rail.js +6 -6
- package/dist/src/reel/layout.d.ts +9 -5
- package/dist/src/reel/layout.d.ts.map +1 -1
- package/dist/src/reel/layout.js +11 -5
- package/dist/src/reel/reel.d.ts.map +1 -1
- package/dist/src/reel/reel.js +122 -68
- package/dist/src/scheme/scheme.d.ts +1 -1
- package/dist/src/scheme/scheme.d.ts.map +1 -1
- package/dist/src/segmented/segmented.d.ts +0 -3
- package/dist/src/segmented/segmented.d.ts.map +1 -1
- package/dist/src/segmented/segmented.js +1 -6
- package/dist/src/selectField/selectField.d.ts.map +1 -1
- package/dist/src/selectField/selectField.js +3 -10
- package/dist/src/sortable/index.d.ts +1 -1
- package/dist/src/sortable/index.d.ts.map +1 -1
- package/dist/src/sortable/index.js +1 -1
- package/dist/src/sortable/sortable.d.ts +39 -40
- package/dist/src/sortable/sortable.d.ts.map +1 -1
- package/dist/src/sortable/sortable.js +14 -31
- package/dist/src/stack/stack.d.ts +1 -1
- package/dist/src/stack/stack.d.ts.map +1 -1
- package/dist/src/stack/stack.js +1 -1
- package/dist/src/tabs/tabs.d.ts +1 -1
- package/dist/src/tabs/tabs.d.ts.map +1 -1
- package/dist/src/tabs/tabs.js +1 -1
- package/dist/src/textareaField/textareaField.d.ts.map +1 -1
- package/dist/src/textareaField/textareaField.js +3 -7
- package/dist/src/time/time.d.ts.map +1 -1
- package/dist/src/time/time.js +4 -2
- package/dist/src/tips/index.d.ts +1 -1
- package/dist/src/tips/index.d.ts.map +1 -1
- package/dist/src/toast/index.d.ts +1 -1
- package/dist/src/toast/index.d.ts.map +1 -1
- package/dist/src/toast/toast.d.ts +5 -5
- package/dist/src/toast/toast.d.ts.map +1 -1
- package/dist/src/toast/toast.js +1 -6
- package/dist/src/toolbar/toolbar.d.ts +0 -3
- package/dist/src/toolbar/toolbar.d.ts.map +1 -1
- package/dist/src/toolbar/toolbar.js +1 -2
- package/package.json +1 -1
- package/src/adapters/mermaid.ts +0 -24
- package/src/announcer/announcer.ts +13 -17
- package/src/board/board.ts +32 -80
- package/src/board/index.ts +1 -1
- package/src/button/button.ts +1 -1
- package/src/commandPalette/commandPalette.ts +21 -38
- package/src/commandPalette/keys.ts +2 -4
- package/src/commandPalette/match.ts +3 -3
- package/src/confirmDialog/confirmDialog.ts +5 -3
- package/src/copyButton/copyButton.ts +2 -5
- package/src/crumbs/crumbs.ts +2 -4
- package/src/dialog/dialog.ts +3 -2
- package/src/drag/drag.ts +54 -5
- package/src/field/field.ts +29 -7
- package/src/fieldset/fieldset.ts +2 -4
- package/src/fileTree/fileTree.ts +10 -12
- package/src/inlineInput/inlineInput.ts +11 -2
- package/src/keyHelp/index.ts +0 -1
- package/src/keyHelp/keyHelp.ts +3 -9
- package/src/keyHint/keyLabel.ts +5 -2
- package/src/lineDiff/diff.ts +70 -54
- package/src/lineDiff/patch.ts +27 -14
- package/src/linkState/linkState.ts +1 -8
- package/src/menu/slip.ts +2 -2
- package/src/meter/meter.ts +25 -15
- package/src/notice/notice.ts +2 -1
- package/src/passwordField/passwordField.ts +3 -7
- package/src/pixel-paper.css +82 -131
- package/src/rail/rail.ts +8 -6
- package/src/reel/layout.ts +14 -7
- package/src/reel/reel.ts +132 -63
- package/src/scheme/scheme.ts +1 -1
- package/src/segmented/segmented.ts +1 -9
- package/src/selectField/selectField.ts +3 -10
- package/src/sortable/index.ts +0 -1
- package/src/sortable/sortable.ts +35 -54
- package/src/stack/stack.ts +1 -1
- package/src/tabs/tabs.ts +1 -1
- package/src/textareaField/textareaField.ts +3 -7
- package/src/time/time.ts +6 -7
- package/src/tips/index.ts +1 -1
- package/src/toast/index.ts +1 -1
- package/src/toast/toast.ts +2 -8
- package/src/tokens.css +6 -0
- package/src/toolbar/toolbar.ts +0 -5
- package/dist/src/inlineInput/inline.d.ts +0 -6
- package/dist/src/inlineInput/inline.d.ts.map +0 -1
- package/dist/src/inlineInput/inline.js +0 -7
- package/src/inlineInput/inline.ts +0 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
2
|
import { Input as UiInput } from "@foldkit/ui";
|
|
3
|
-
import { Effect, Match, Option, Schema } from "effect";
|
|
3
|
+
import { Effect, Match, Option, Schema, String, pipe } from "effect";
|
|
4
4
|
import * as Command from "foldkit/command";
|
|
5
5
|
import * as Dom from "foldkit/dom";
|
|
6
6
|
import {} from "foldkit/html";
|
|
@@ -12,7 +12,6 @@ import { defineView } from "foldkit/submodel";
|
|
|
12
12
|
import * as Update from "foldkit/update";
|
|
13
13
|
import { isPlain } from "../keys/keys.js";
|
|
14
14
|
import * as Notice from "../notice/notice.js";
|
|
15
|
-
import { toWrite } from "./inline.js";
|
|
16
15
|
// MODEL
|
|
17
16
|
/** What started a save: Enter, or leaving the field. */
|
|
18
17
|
const SaveTrigger = Schema.Literals(["Enter", "Blur"]);
|
|
@@ -99,6 +98,10 @@ const end = (model, how) => (__foldkitBrandViewResult(({
|
|
|
99
98
|
model: modifyFields(model, { phase: () => __foldkitBrandViewResult((Phase.Ended()), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#phase") }),
|
|
100
99
|
outMessage: OutMessage.Ended({ how, maybeLastSavedId: model.maybeLastSavedId }),
|
|
101
100
|
}), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#end"));
|
|
101
|
+
/** What Enter or leaving an inline field writes: the draft trimmed, or none (an untouched
|
|
102
|
+
* draft, so an edit made elsewhere to `value` is never overwritten; an empty one; or the
|
|
103
|
+
* text it replaces). */
|
|
104
|
+
export const toWrite = (maybeDraft, value) => __foldkitBrandViewResult((pipe(maybeDraft, Option.map(String.trim), Option.filter((text) => __foldkitBrandViewResult((String.isNonEmpty(text) && text !== value), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~2")))), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#toWrite");
|
|
102
105
|
const commit = (model, trigger) => __foldkitBrandViewResult((Option.match(toWrite(model.maybeDraft, model.replaced), {
|
|
103
106
|
onNone: () => __foldkitBrandViewResult((end(model, trigger)), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#onNone"),
|
|
104
107
|
onSome: (text) => (__foldkitBrandViewResult(({
|
|
@@ -171,7 +174,7 @@ export const failed = (model, error) => __foldkitBrandViewResult((Phase.guards.S
|
|
|
171
174
|
* alone. */
|
|
172
175
|
export const fieldKey = (event) => __foldkitBrandViewResult((event.isComposing || event.defaultPrevented || !isPlain(event)
|
|
173
176
|
? Option.none()
|
|
174
|
-
: Match.value(event.key).pipe(Match.withReturnType(), Match.when("Enter", () => __foldkitBrandViewResult((Option.some(Message.PressedEnter())), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~
|
|
177
|
+
: Match.value(event.key).pipe(Match.withReturnType(), Match.when("Enter", () => __foldkitBrandViewResult((Option.some(Message.PressedEnter())), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~3")), Match.when("Escape", () => __foldkitBrandViewResult((Option.some(Message.PressedEscape())), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~4")), Match.orElse(() => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~5")))), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#fieldKey");
|
|
175
178
|
/** The field's keys: Enter saves (or ends, with nothing new to save) and Escape discards and
|
|
176
179
|
* ends, while the edit is open. A key an IME is composing, a modified key and a key someone
|
|
177
180
|
* already handled are left alone; a key it takes has its default prevented, so an Escape here
|
|
@@ -188,7 +191,7 @@ export const BindFieldKeys = Mount.defineStream("BindFieldKeys", {
|
|
|
188
191
|
// VIEW
|
|
189
192
|
/** How tall the field is: a row's words, or a card's 16px title. */
|
|
190
193
|
export const Size = Schema.Literals(["Row", "Title"]);
|
|
191
|
-
const shownError = (model, error) => __foldkitBrandViewResult((Option.orElse(Option.fromNullishOr(error), () => __foldkitBrandViewResult((model.maybeError), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~
|
|
194
|
+
const shownError = (model, error) => __foldkitBrandViewResult((Option.orElse(Option.fromNullishOr(error), () => __foldkitBrandViewResult((model.maybeError), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~6"))), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#shownError");
|
|
192
195
|
/**
|
|
193
196
|
* Text edited in place: an input that takes exactly the height of what it replaces, built on
|
|
194
197
|
* `@foldkit/ui`'s Input. Enter or leaving the field with new text reports `Committed`; the
|
|
@@ -203,7 +206,7 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
203
206
|
const hasError = Option.isSome(shownError(model, error));
|
|
204
207
|
return __foldkitBrandViewResult((UiInput.view({
|
|
205
208
|
id: model.id,
|
|
206
|
-
value: Option.getOrElse(model.maybeDraft, () => __foldkitBrandViewResult((value), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~
|
|
209
|
+
value: Option.getOrElse(model.maybeDraft, () => __foldkitBrandViewResult((value), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~8")),
|
|
207
210
|
onInput: (draft) => __foldkitBrandViewResult((Message.UpdatedDraft({ value: draft, replaced: value })), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#onInput"),
|
|
208
211
|
isReadOnly: isHeld,
|
|
209
212
|
isInvalid: hasError,
|
|
@@ -218,7 +221,7 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
218
221
|
h.OnMount(BindFieldKeys()),
|
|
219
222
|
h.Class(size === "Title" ? "inline-input title-edit" : "inline-input"),
|
|
220
223
|
])), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#toView"),
|
|
221
|
-
}, h)), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~
|
|
224
|
+
}, h)), "@gjermundgaraba-designs/pixel-paper/src/inlineInput/inlineInput.js#anonymous~7");
|
|
222
225
|
});
|
|
223
226
|
/** Why the field is marked: the caller's `error`, else why the last save was refused, as an
|
|
224
227
|
* error Notice with the id the field points at, or nothing. Place it under the field and
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { HELP_KEYS, Message, Model, OutMessage,
|
|
1
|
+
export { HELP_KEYS, Message, Model, OutMessage, id, helpBinding, init, isOpen, open, subscriptions, toKeymapGroups, update, view, } from "./keyHelp.ts";
|
|
2
2
|
export type { Binding, InitConfig, ViewInputs } from "./keyHelp.ts";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/keyHelp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,KAAK,EACL,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/keyHelp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,KAAK,EACL,UAAU,EACV,EAAE,EACF,WAAW,EACX,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,aAAa,EACb,cAAc,EACd,MAAM,EACN,IAAI,GACL,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { HELP_KEYS, Message, Model, OutMessage,
|
|
1
|
+
export { HELP_KEYS, Message, Model, OutMessage, id, helpBinding, init, isOpen, open, subscriptions, toKeymapGroups, update, view, } from "./keyHelp.js";
|
|
@@ -78,7 +78,7 @@ export declare const Message: import("foldkit/message").MessageUnion<{
|
|
|
78
78
|
}>;
|
|
79
79
|
export type Message = typeof Message.Type;
|
|
80
80
|
/** Union of OutMessages the key help reports: the reader closed it (Escape, a click on the
|
|
81
|
-
* veil, a close button). Opening it, by `?` or `open`,
|
|
81
|
+
* veil, a close button). Opening it, by `?` or `open`, reports nothing. */
|
|
82
82
|
export declare const OutMessage: import("foldkit/message").MessageUnion<{
|
|
83
83
|
readonly Closed: {};
|
|
84
84
|
}>;
|
|
@@ -160,8 +160,6 @@ export declare const update: (model: Model, message: Message) => Readonly<{
|
|
|
160
160
|
}>;
|
|
161
161
|
/** Opens the key help, as `?` does: for a button or a command palette entry. */
|
|
162
162
|
export declare const open: (model: Model) => Update.Return<Model, Message>;
|
|
163
|
-
/** Closes the key help without reporting `Closed`. */
|
|
164
|
-
export declare const close: (model: Model) => Update.Return<Model, Message>;
|
|
165
163
|
/** The key help's id, unique in the document. */
|
|
166
164
|
export declare const id: (model: Model) => string;
|
|
167
165
|
/** Whether the key help is open. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyHelp.d.ts","sourceRoot":"","sources":["../../../src/keyHelp/keyHelp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAgB,MAAM,QAAQ,CAAC;AAEhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,cAAc,CAAC;AAItD,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAOzC,OAAO,EAAE,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"keyHelp.d.ts","sourceRoot":"","sources":["../../../src/keyHelp/keyHelp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAgB,MAAM,QAAQ,CAAC;AAEhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,cAAc,CAAC;AAItD,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAOzC,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,wBAAwB,CAAC;AAC/E,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAI9C,2E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AEpE,oCAAoC;AACpC,eAAO,MAAM,MAAM,UAAW,KAAK,KAAG,OAAsC,CAAC;AAI7E,8FAA8F;AAC9F,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBvB,CAAC;AAYJ;8FAC8F;AAC9F,eAAO,MAAM,cAAc,aACf,aAAa,CAAC,OAAO,CAAC,YACtB,WAAW,SACd,MAAM,KACZ,aAAa,CAAC,MAAM,CAAC,WAAW,CA2BlC,CAAC;AAIF,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,8DAA8D;IAC9D,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACjC,QAAQ,EAAE,WAAW,CAAC;IACtB;;+DAE2D;IAC3D,WAAW,CAAC,EAAE,MAAM,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IACjD;0CACsC;IACtC,gBAAgB,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;CAC7C,CAAC,CAAC;AAsDH;;qBAEqB;AACrB,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAnEf,8DAA8D;cACpD,aAAa,CAAC,OAAO,CAAC;cACtB,WAAW;IACrB;;+DAE2D;kBAC7C,MAAM,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC;IAChD;0CACsC;uBACnB,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS;GAqE5C,CAAC"}
|
|
@@ -11,7 +11,7 @@ import * as Card from "../card/card.js";
|
|
|
11
11
|
import * as Dialog from "../dialog/dialog.js";
|
|
12
12
|
import { foldDialog } from "../dialog/fold.js";
|
|
13
13
|
import * as Field from "../field/field.js";
|
|
14
|
-
import { keyLabel } from "../keyHint/keyLabel.js";
|
|
14
|
+
import { keyLabel, pressesOf } from "../keyHint/keyLabel.js";
|
|
15
15
|
import * as Keymap from "../keymap/keymap.js";
|
|
16
16
|
// MODEL
|
|
17
17
|
/** Schema for the key help: its Dialog and the words in its find field. */
|
|
@@ -32,7 +32,7 @@ export const Message = defineMessageUnion({
|
|
|
32
32
|
});
|
|
33
33
|
// OUT MESSAGE
|
|
34
34
|
/** Union of OutMessages the key help reports: the reader closed it (Escape, a click on the
|
|
35
|
-
* veil, a close button). Opening it, by `?` or `open`,
|
|
35
|
+
* veil, a close button). Opening it, by `?` or `open`, reports nothing. */
|
|
36
36
|
export const OutMessage = defineMessageUnion({
|
|
37
37
|
Closed: {},
|
|
38
38
|
});
|
|
@@ -60,8 +60,6 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
60
60
|
})), "@gjermundgaraba-designs/pixel-paper/src/keyHelp/keyHelp.js#update");
|
|
61
61
|
/** Opens the key help, as `?` does: for a button or a command palette entry. */
|
|
62
62
|
export const open = (model) => __foldkitBrandViewResult((dialogFold.open(clearQuery(model))), "@gjermundgaraba-designs/pixel-paper/src/keyHelp/keyHelp.js#open");
|
|
63
|
-
/** Closes the key help without reporting `Closed`. */
|
|
64
|
-
export const close = (model) => __foldkitBrandViewResult((dialogFold.close(model)), "@gjermundgaraba-designs/pixel-paper/src/keyHelp/keyHelp.js#close");
|
|
65
63
|
// ACCESSORS
|
|
66
64
|
/** The key help's id, unique in the document. */
|
|
67
65
|
export const id = (model) => __foldkitBrandViewResult((Dialog.id(model.dialog)), "@gjermundgaraba-designs/pixel-paper/src/keyHelp/keyHelp.js#id");
|
|
@@ -84,8 +82,7 @@ export const subscriptions = Subscription.make()((entry) => (__foldkitBrandViewR
|
|
|
84
82
|
}),
|
|
85
83
|
}), "@gjermundgaraba-designs/pixel-paper/src/keyHelp/keyHelp.js#anonymous")));
|
|
86
84
|
// LISTING
|
|
87
|
-
const
|
|
88
|
-
const isFound = (binding, labels, query) => __foldkitBrandViewResult((pipe([labels, ...Array.flatMap(binding.keys, keysOf), binding.does, binding.group], Array.join(" "), String.toLowerCase, String.includes(query))), "@gjermundgaraba-designs/pixel-paper/src/keyHelp/keyHelp.js#isFound");
|
|
85
|
+
const isFound = (binding, labels, query) => __foldkitBrandViewResult((pipe([labels, ...Array.flatMap(binding.keys, pressesOf), binding.does, binding.group], Array.join(" "), String.toLowerCase, String.includes(query))), "@gjermundgaraba-designs/pixel-paper/src/keyHelp/keyHelp.js#isFound");
|
|
89
86
|
/** The bindings as a keymap: under their groups in the order the groups first appear, each
|
|
90
87
|
* binding's keys printed for the platform, filtered by the query (its keys or its words). */
|
|
91
88
|
export const toKeymapGroups = (bindings, platform, query) => {
|
|
@@ -10,6 +10,8 @@ export declare const keyPlatformOf: (userAgent: string) => KeyPlatform;
|
|
|
10
10
|
/** The reader's key platform, from the browser's user agent (`keyPlatformOf`). `Other` where
|
|
11
11
|
* there is no navigator, as during a server render. */
|
|
12
12
|
export declare const detectKeyPlatform: Effect.Effect<KeyPlatform>;
|
|
13
|
+
/** The presses a binding's keys name: one, or a sequence. */
|
|
14
|
+
export declare const pressesOf: (keys: KeySequence) => ReadonlyArray<string>;
|
|
13
15
|
/**
|
|
14
16
|
* A key binding as the help and the key hints print it. Takes the same strings
|
|
15
17
|
* `Dom.streamFromKeyBindings` matches: `"Mod+K"` prints `⌘K` on Apple and `Ctrl+K` elsewhere,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyLabel.d.ts","sourceRoot":"","sources":["../../../src/keyHint/keyLabel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAoC,MAAM,EAAgB,MAAM,QAAQ,CAAC;AAC/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C;8FAC8F;AAC9F,eAAO,MAAM,WAAW,8CAAsC,CAAC;AAC/D,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;AAIlD;6DAC6D;AAC7D,eAAO,MAAM,aAAa,cAAe,MAAM,KAAG,WACU,CAAC;AAE7D;wDACwD;AACxD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAExD,CAAC;AA2FF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,SAAU,WAAW,YAAY,WAAW,KAAG,
|
|
1
|
+
{"version":3,"file":"keyLabel.d.ts","sourceRoot":"","sources":["../../../src/keyHint/keyLabel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAoC,MAAM,EAAgB,MAAM,QAAQ,CAAC;AAC/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C;8FAC8F;AAC9F,eAAO,MAAM,WAAW,8CAAsC,CAAC;AAC/D,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;AAIlD;6DAC6D;AAC7D,eAAO,MAAM,aAAa,cAAe,MAAM,KAAG,WACU,CAAC;AAE7D;wDACwD;AACxD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAExD,CAAC;AA2FF,6DAA6D;AAC7D,eAAO,MAAM,SAAS,SAAU,WAAW,KAAG,aAAa,CAAC,MAAM,CACxB,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,SAAU,WAAW,YAAY,WAAW,KAAG,MAInE,CAAC"}
|
|
@@ -63,6 +63,8 @@ const pressLabel = (press, platform) => {
|
|
|
63
63
|
const prefix = Array.join(Array.map(orderedModifiers, (modifier) => __foldkitBrandViewResult((platform === "Apple" ? APPLE_SYMBOL[modifier] : OTHER_PREFIX[modifier]), "@gjermundgaraba-designs/pixel-paper/src/keyHint/keyLabel.js#anonymous~10")), "");
|
|
64
64
|
return __foldkitBrandViewResult((`${prefix}${keyName(key, Array.isReadonlyArrayNonEmpty(orderedModifiers))}`), "@gjermundgaraba-designs/pixel-paper/src/keyHint/keyLabel.js#pressLabel");
|
|
65
65
|
};
|
|
66
|
+
/** The presses a binding's keys name: one, or a sequence. */
|
|
67
|
+
export const pressesOf = (keys) => __foldkitBrandViewResult((Predicate.isString(keys) ? [keys] : keys), "@gjermundgaraba-designs/pixel-paper/src/keyHint/keyLabel.js#pressesOf");
|
|
66
68
|
/**
|
|
67
69
|
* A key binding as the help and the key hints print it. Takes the same strings
|
|
68
70
|
* `Dom.streamFromKeyBindings` matches: `"Mod+K"` prints `⌘K` on Apple and `Ctrl+K` elsewhere,
|
|
@@ -72,7 +74,6 @@ const pressLabel = (press, platform) => {
|
|
|
72
74
|
* named key keeps its spaces.
|
|
73
75
|
*/
|
|
74
76
|
export const keyLabel = (keys, platform) => {
|
|
75
|
-
const
|
|
76
|
-
const labels = Array.map(presses, (press) => __foldkitBrandViewResult((pressLabel(press, platform)), "@gjermundgaraba-designs/pixel-paper/src/keyHint/keyLabel.js#anonymous~11"));
|
|
77
|
+
const labels = Array.map(pressesOf(keys), (press) => __foldkitBrandViewResult((pressLabel(press, platform)), "@gjermundgaraba-designs/pixel-paper/src/keyHint/keyLabel.js#anonymous~11"));
|
|
77
78
|
return __foldkitBrandViewResult((Array.every(labels, isCharacter) ? Array.join(labels, "") : Array.join(labels, " ")), "@gjermundgaraba-designs/pixel-paper/src/keyHint/keyLabel.js#keyLabel");
|
|
78
79
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type StructuredPatchHunk } from "diff";
|
|
2
|
+
import { Array, Option, Schema } from "effect";
|
|
2
3
|
/** A row of a diff: a line, numbered on the side or sides it is on, or a run of unchanged
|
|
3
4
|
* lines folded into a count, known by its first line's old number. */
|
|
4
5
|
export declare const DiffRow: import("foldkit/schema").TaggedUnion<{
|
|
@@ -28,9 +29,11 @@ export type LineKind = "Same" | "Added" | "Removed";
|
|
|
28
29
|
export declare const diffRowsOf: (before: string, after: string) => ReadonlyArray<DiffRow>;
|
|
29
30
|
/** Whether a line was added or removed. */
|
|
30
31
|
export declare const hasChanges: (rows: ReadonlyArray<DiffRow>) => boolean;
|
|
31
|
-
/** The
|
|
32
|
-
* lines between hunks folded into a count. `None` unless it is one file with a hunk: text that
|
|
32
|
+
/** The hunks of one file's unified diff. `None` unless it is one file with a hunk: text that
|
|
33
33
|
* is not a diff, a binary change and several files have no lines to show. */
|
|
34
|
+
export declare const hunksOfPatch: (patch: string) => Option.Option<Array.NonEmptyReadonlyArray<StructuredPatchHunk>>;
|
|
35
|
+
/** The rows of one file's unified diff, numbered from its hunks' headers, with the unchanged
|
|
36
|
+
* lines between hunks folded into a count. `None` where `hunksOfPatch` is. */
|
|
34
37
|
export declare const diffRowsOfPatch: (patch: string) => Option.Option<ReadonlyArray<DiffRow>>;
|
|
35
38
|
/** The diff's rows: every change with `context` unchanged lines around it, and each longer
|
|
36
39
|
* run of unchanged lines folded into one row that counts them (a run of one stays a line). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/lineDiff/diff.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/lineDiff/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAyB,MAAM,MAAM,CAAC;AACvE,OAAO,EAAE,KAAK,EAAS,MAAM,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAK5D;uEACuE;AACvE,eAAO,MAAM,OAAO;;QACV,IAAI;QAAiB,SAAS;QAAiB,SAAS;;;QACvD,IAAI;QAAiB,SAAS;;;QAC5B,IAAI;QAAiB,SAAS;;;QACjC,KAAK;QAAiB,cAAc;;EAC5C,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAI1C,6CAA6C;AAC7C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAwCpD;6CAC6C;AAC7C,eAAO,MAAM,UAAU,WAAY,MAAM,SAAS,MAAM,KAAG,aAAa,CAAC,OAAO,CAU7E,CAAC;AAIJ,2CAA2C;AAC3C,eAAO,MAAM,UAAU,SAAU,aAAa,CAAC,OAAO,CAAC,KAAG,OAAqC,CAAC;AAiDhG;8EAC8E;AAC9E,eAAO,MAAM,YAAY,UAChB,MAAM,KACZ,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,mBAAmB,CAAC,CACK,CAAC;AAEvE;+EAC+E;AAC/E,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CACc,CAAC;AAenG;+FAC+F;AAC/F,eAAO,MAAM,aAAa,SAClB,aAAa,CAAC,OAAO,CAAC,WACnB,MAAM,KACd,aAAa,CAAC,OAAO,CA0BvB,CAAC"}
|
|
@@ -23,14 +23,17 @@ const numberLine = (numbers, kind, text) => __foldkitBrandViewResult((Match.valu
|
|
|
23
23
|
{ old: numbers.old + 1, new: numbers.new },
|
|
24
24
|
DiffRow.Removed({ text, oldNumber: numbers.old }),
|
|
25
25
|
]), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~6")), Match.exhaustive)), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#numberLine");
|
|
26
|
+
const numbered = (lines, from) => __foldkitBrandViewResult((Array.mapAccum(lines, from, (numbers, { kind, text }) => __foldkitBrandViewResult((numberLine(numbers, kind, text)), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~7"))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#numbered");
|
|
26
27
|
/** The line diff of two texts (Myers, through jsdiff), each line numbered on its side. A
|
|
27
28
|
* missing final newline is not a change. */
|
|
28
29
|
export const diffRowsOf = (before, after) => __foldkitBrandViewResult((pipe(diffLines(withFinalNewline(before), withFinalNewline(after)), Array.flatMap((change) => __foldkitBrandViewResult((Array.map(change.value.slice(0, -1).split("\n"), (text) => (__foldkitBrandViewResult(({
|
|
29
30
|
kind: changeKind(change),
|
|
30
31
|
text,
|
|
31
|
-
}), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~
|
|
32
|
+
}), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~9")))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~8")), (lines) => __foldkitBrandViewResult((numbered(lines, { old: 1, new: 1 })[1]), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~10"))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#diffRowsOf");
|
|
33
|
+
const isChange = (row) => __foldkitBrandViewResult((row._tag === "Added" || row._tag === "Removed"), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#isChange");
|
|
32
34
|
/** Whether a line was added or removed. */
|
|
33
|
-
export const hasChanges = (rows) => __foldkitBrandViewResult((Array.some(rows,
|
|
35
|
+
export const hasChanges = (rows) => __foldkitBrandViewResult((Array.some(rows, isChange)), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#hasChanges");
|
|
36
|
+
// PATCH
|
|
34
37
|
const LINE_KIND_BY_PREFIX = {
|
|
35
38
|
" ": "Same",
|
|
36
39
|
"+": "Added",
|
|
@@ -39,18 +42,17 @@ const LINE_KIND_BY_PREFIX = {
|
|
|
39
42
|
// a blank context line that lost its leading space on the way (a trimming editor, a mail) is
|
|
40
43
|
// still a context line
|
|
41
44
|
const kindOf = (line) => __foldkitBrandViewResult((line === "" ? Option.some("Same") : Option.fromUndefinedOr(LINE_KIND_BY_PREFIX[line.charAt(0)])), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#kindOf");
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~13"))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#readHunk");
|
|
45
|
+
// "" starts with a "\", a prefix that draws no row
|
|
46
|
+
const linesOf = (hunk) => __foldkitBrandViewResult((Array.getSomes(Array.map(hunk.lines, (line) => __foldkitBrandViewResult((Option.map(kindOf(line), (kind) => (__foldkitBrandViewResult(({ kind, text: line.slice(1) }), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~12")))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~11")))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#linesOf");
|
|
47
|
+
// each hunk is numbered from its own header; only the gap before it needs the old line the
|
|
48
|
+
// previous one ended on
|
|
49
|
+
const readHunk = (nextOld, hunk) => {
|
|
50
|
+
const gap = hunk.oldStart - nextOld;
|
|
51
|
+
const [end, rows] = numbered(linesOf(hunk), { old: hunk.oldStart, new: hunk.newStart });
|
|
52
|
+
return __foldkitBrandViewResult(([
|
|
53
|
+
end.old,
|
|
54
|
+
gap > 0 ? [DiffRow.Fold({ count: gap, firstOldNumber: nextOld }), ...rows] : rows,
|
|
55
|
+
]), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#readHunk");
|
|
54
56
|
};
|
|
55
57
|
const onlyHunksOf = (files) => __foldkitBrandViewResult((Array.match(files, {
|
|
56
58
|
onEmpty: () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#onEmpty"),
|
|
@@ -58,23 +60,33 @@ const onlyHunksOf = (files) => __foldkitBrandViewResult((Array.match(files, {
|
|
|
58
60
|
? Option.some(file.hunks)
|
|
59
61
|
: Option.none()), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#onNonEmpty"),
|
|
60
62
|
})), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#onlyHunksOf");
|
|
61
|
-
/** The
|
|
62
|
-
* lines between hunks folded into a count. `None` unless it is one file with a hunk: text that
|
|
63
|
+
/** The hunks of one file's unified diff. `None` unless it is one file with a hunk: text that
|
|
63
64
|
* is not a diff, a binary change and several files have no lines to show. */
|
|
64
|
-
export const
|
|
65
|
+
export const hunksOfPatch = (patch) => __foldkitBrandViewResult((Option.flatMap(Option.liftThrowable(parsePatch)(patch), onlyHunksOf)), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#hunksOfPatch");
|
|
66
|
+
/** The rows of one file's unified diff, numbered from its hunks' headers, with the unchanged
|
|
67
|
+
* lines between hunks folded into a count. `None` where `hunksOfPatch` is. */
|
|
68
|
+
export const diffRowsOfPatch = (patch) => __foldkitBrandViewResult((Option.map(hunksOfPatch(patch), (hunks) => __foldkitBrandViewResult((Array.flatten(Array.mapAccum(hunks, 1, readHunk)[1])), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~13"))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#diffRowsOfPatch");
|
|
65
69
|
// a run of one stays a line: a row that says "1 unchanged line" takes the same room as the line
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
: DiffRow.Fold({ count
|
|
69
|
-
|
|
70
|
-
onEmpty: () => __foldkitBrandViewResult((rows), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#onEmpty~2"),
|
|
71
|
-
onNonEmpty: (run) => __foldkitBrandViewResult(([...rows, foldRow(run)]), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#onNonEmpty~2"),
|
|
72
|
-
})), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#flushFold");
|
|
70
|
+
const runRows = (maybeRun) => __foldkitBrandViewResult((Option.match(maybeRun, {
|
|
71
|
+
onNone: () => __foldkitBrandViewResult(([]), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#onNone"),
|
|
72
|
+
onSome: ({ first, count }) => __foldkitBrandViewResult((count === 1 ? [first] : [DiffRow.Fold({ count, firstOldNumber: first.oldNumber })]), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#onSome"),
|
|
73
|
+
})), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#runRows");
|
|
73
74
|
/** The diff's rows: every change with `context` unchanged lines around it, and each longer
|
|
74
75
|
* run of unchanged lines folded into one row that counts them (a run of one stays a line). */
|
|
75
76
|
export const foldUnchanged = (rows, context) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
// the changes before each index, so the changes in any window are one subtraction
|
|
78
|
+
const changesBefore = Array.scan(rows, 0, (count, row) => __foldkitBrandViewResult((count + (isChange(row) ? 1 : 0)), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~14"));
|
|
79
|
+
const isKept = (index) => __foldkitBrandViewResult((Array.getUnsafe(changesBefore, Math.min(rows.length, index + context + 1)) -
|
|
80
|
+
Array.getUnsafe(changesBefore, Math.max(0, index - context)) >
|
|
81
|
+
0), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#isKept");
|
|
82
|
+
const [maybeRun, kept] = Array.mapAccum(rows, Option.none(), (maybeRun, row, index) => __foldkitBrandViewResult((row._tag === "Same" && !isKept(index)
|
|
83
|
+
? [
|
|
84
|
+
Option.some(Option.match(maybeRun, {
|
|
85
|
+
onNone: () => (__foldkitBrandViewResult(({ first: row, count: 1 }), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#onNone~2")),
|
|
86
|
+
onSome: (run) => (__foldkitBrandViewResult(({ ...run, count: run.count + 1 }), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#onSome~2")),
|
|
87
|
+
})),
|
|
88
|
+
[],
|
|
89
|
+
]
|
|
90
|
+
: [Option.none(), [...runRows(maybeRun), row]]), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#anonymous~15"));
|
|
91
|
+
return __foldkitBrandViewResult(([...Array.flatten(kept), ...runRows(maybeRun)]), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/diff.js#foldUnchanged");
|
|
80
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../src/lineDiff/patch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAgB,MAAM,QAAQ,CAAC;AAErD,OAAO,EAAE,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../src/lineDiff/patch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAgB,MAAM,QAAQ,CAAC;AAErD,OAAO,EAAE,KAAK,OAAO,EAAiC,MAAM,WAAW,CAAC;AAgCxE;4DAC4D;AAC5D,eAAO,MAAM,QAAQ,SAAU,MAAM,KAAG,MAO9B,CAAC;AAsCX,0CAA0C;AAC1C,eAAO,MAAM,SAAS,kDAAkD,CAAC;AAIzE,wFAAwF;AACxF,KAAK,KAAK,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CAAC;AAE1F,oEAAoE;AACpE,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC9B,CAAC,CAAC;AA+GH,sFAAsF;AACtF,eAAO,MAAM,SAAS,UAAW,MAAM,KAAG,YAAqD,CAAC;AAIhG,oEAAoE;AACpE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,mFAAmF;IACnF,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxC;;gCAE4B;IAC5B,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC9B,CAAC,CAAC;AAEH;;mBAEmB;AACnB,eAAO,MAAM,aAAa,UAAW,MAAM,KAAG,gBAO7C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
2
|
import { Array, Option, String, pipe } from "effect";
|
|
3
|
-
import { diffRowsOfPatch } from "./diff.js";
|
|
3
|
+
import { diffRowsOfPatch, hunksOfPatch } from "./diff.js";
|
|
4
4
|
// QUOTED PATHS
|
|
5
5
|
const ESCAPED_BYTES = {
|
|
6
6
|
a: 7,
|
|
@@ -76,9 +76,9 @@ const lineNote = (head, hasRows) => {
|
|
|
76
76
|
return __foldkitBrandViewResult((Option.none()), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#lineNote");
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
const readSection = (section) => {
|
|
79
|
+
const readSection = (section, rowsOf) => {
|
|
80
80
|
const head = headOf(section);
|
|
81
|
-
const maybeRows =
|
|
81
|
+
const maybeRows = rowsOf(section);
|
|
82
82
|
const maybeRenamedFrom = Option.map(valueAfter(head, "rename from "), unquoted);
|
|
83
83
|
const notes = [
|
|
84
84
|
...Option.toArray(Option.map(maybeRenamedFrom, (from) => __foldkitBrandViewResult((`Renamed from ${from}.`), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#anonymous~3"))),
|
|
@@ -101,10 +101,10 @@ const KINDS = {
|
|
|
101
101
|
"160000": "a submodule",
|
|
102
102
|
};
|
|
103
103
|
const kindOf = (mode) => __foldkitBrandViewResult((KINDS[mode] ?? `mode ${mode}`), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#kindOf");
|
|
104
|
-
const sideTable = (section, side) => __foldkitBrandViewResult((Option.toArray(Option.map(
|
|
104
|
+
const sideTable = (section, side, rowsOf) => __foldkitBrandViewResult((Option.toArray(Option.map(rowsOf(section), (rows) => (__foldkitBrandViewResult(({ rows, maybeSide: Option.some(side) }), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#anonymous~6"))))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#sideTable");
|
|
105
105
|
// a file that became a symlink (or any other kind) is two sections for one path: the old
|
|
106
106
|
// kind deleted, then the new one added
|
|
107
|
-
const readTypeChange = (gone, added) => {
|
|
107
|
+
const readTypeChange = (gone, added, rowsOf) => {
|
|
108
108
|
const [goneHead, addedHead] = [headOf(gone), headOf(added)];
|
|
109
109
|
return __foldkitBrandViewResult((Option.flatMap(Option.all({
|
|
110
110
|
before: valueAfter(goneHead, "deleted file mode "),
|
|
@@ -113,34 +113,39 @@ const readTypeChange = (gone, added) => {
|
|
|
113
113
|
? Option.some({
|
|
114
114
|
maybeRenamedFrom: Option.none(),
|
|
115
115
|
notes: [`It was ${kindOf(before)} and is now ${kindOf(after)}.`],
|
|
116
|
-
tables: [
|
|
116
|
+
tables: [
|
|
117
|
+
...sideTable(gone, "as it was", rowsOf),
|
|
118
|
+
...sideTable(added, "as it is", rowsOf),
|
|
119
|
+
],
|
|
117
120
|
})
|
|
118
121
|
: Option.none()), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#anonymous~7"))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#readTypeChange");
|
|
119
122
|
};
|
|
120
|
-
|
|
121
|
-
export const readPatch = (patch) => {
|
|
123
|
+
const readPatchWith = (patch, rowsOf) => {
|
|
122
124
|
const text = patch.replaceAll("\r\n", "\n");
|
|
123
125
|
if (String.isEmpty(String.trim(text))) {
|
|
124
|
-
return __foldkitBrandViewResult(({ maybeRenamedFrom: Option.none(), notes: [SAME_NOTE], tables: [] }), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#
|
|
126
|
+
return __foldkitBrandViewResult(({ maybeRenamedFrom: Option.none(), notes: [SAME_NOTE], tables: [] }), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#readPatchWith");
|
|
125
127
|
}
|
|
126
128
|
else {
|
|
127
129
|
const sections = sectionsOf(text);
|
|
128
130
|
const [first, second, ...rest] = sections;
|
|
129
131
|
if (first !== undefined && second === undefined) {
|
|
130
|
-
return __foldkitBrandViewResult((readSection(first)), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#
|
|
132
|
+
return __foldkitBrandViewResult((readSection(first, rowsOf)), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#readPatchWith");
|
|
131
133
|
}
|
|
132
134
|
else if (first !== undefined && second !== undefined && Array.isArrayEmpty(rest)) {
|
|
133
|
-
return __foldkitBrandViewResult((Option.getOrElse(readTypeChange(first, second), () => __foldkitBrandViewResult((unreadable), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#anonymous~8"))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#
|
|
135
|
+
return __foldkitBrandViewResult((Option.getOrElse(readTypeChange(first, second, rowsOf), () => __foldkitBrandViewResult((unreadable), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#anonymous~8"))), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#readPatchWith");
|
|
134
136
|
}
|
|
135
137
|
else {
|
|
136
|
-
return __foldkitBrandViewResult((unreadable), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#
|
|
138
|
+
return __foldkitBrandViewResult((unreadable), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#readPatchWith");
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
};
|
|
142
|
+
/** What `patchView` makes of a patch: the notes it prints and the tables it draws. */
|
|
143
|
+
export const readPatch = (patch) => __foldkitBrandViewResult((readPatchWith(patch, diffRowsOfPatch)), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#readPatch");
|
|
140
144
|
/** What `patchView` says about a patch from `git diff`, read from its header: the notes it
|
|
141
145
|
* prints (`["Renamed from old.txt."]`), for a caller that prints them itself, and the path a
|
|
142
146
|
* rename left. */
|
|
143
147
|
export const describePatch = (patch) => {
|
|
144
|
-
|
|
148
|
+
// the notes need only whether a section has lines, so none are numbered
|
|
149
|
+
const { maybeRenamedFrom, notes } = readPatchWith(patch, (section) => __foldkitBrandViewResult((Option.as(hunksOfPatch(section), [])), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#anonymous~9"));
|
|
145
150
|
return __foldkitBrandViewResult(({ maybeRenamedFrom, notes }), "@gjermundgaraba-designs/pixel-paper/src/lineDiff/patch.js#describePatch");
|
|
146
151
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkState.d.ts","sourceRoot":"","sources":["../../../src/linkState/linkState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAItD;wFACwF;AACxF,eAAO,MAAM,KAAK,+EAAuE,CAAC;AAC1F,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC;AActC,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"linkState.d.ts","sourceRoot":"","sources":["../../../src/linkState/linkState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAItD;wFACwF;AACxF,eAAO,MAAM,KAAK,+EAAuE,CAAC;AAC1F,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC;AActC,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH;mFACmF;AACnF,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,UAAU,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAQ3E,CAAC"}
|
|
@@ -5,16 +5,10 @@ import { Match, Schema } from "effect";
|
|
|
5
5
|
* coming back, on amber. `Offline`: given up, on red. Both stay visible on a phone. */
|
|
6
6
|
export const State = Schema.Literals(["Online", "Connecting", "Reconnecting", "Offline"]);
|
|
7
7
|
const stateWord = (state) => __foldkitBrandViewResult((Match.value(state).pipe(Match.withReturnType(), Match.when("Online", () => __foldkitBrandViewResult(("online"), "@gjermundgaraba-designs/pixel-paper/src/linkState/linkState.js#anonymous")), Match.when("Connecting", () => __foldkitBrandViewResult(("connecting"), "@gjermundgaraba-designs/pixel-paper/src/linkState/linkState.js#anonymous~2")), Match.when("Reconnecting", () => __foldkitBrandViewResult(("reconnecting"), "@gjermundgaraba-designs/pixel-paper/src/linkState/linkState.js#anonymous~3")), Match.when("Offline", () => __foldkitBrandViewResult(("offline"), "@gjermundgaraba-designs/pixel-paper/src/linkState/linkState.js#anonymous~4")), Match.exhaustive)), "@gjermundgaraba-designs/pixel-paper/src/linkState/linkState.js#stateWord");
|
|
8
|
-
const STATE_CLASS = {
|
|
9
|
-
Online: "",
|
|
10
|
-
Connecting: " connecting",
|
|
11
|
-
Reconnecting: " reconnecting",
|
|
12
|
-
Offline: " offline",
|
|
13
|
-
};
|
|
14
8
|
/** The connection word, in a top bar or a status bar. It is a status (`role="status"`), so a
|
|
15
9
|
* change of state is read out; while it connects it prints the working cursor. */
|
|
16
10
|
export const view = (config, h) => {
|
|
17
11
|
const { state, label = stateWord(state) } = config;
|
|
18
12
|
const isWorking = state === "Connecting" || state === "Reconnecting";
|
|
19
|
-
return __foldkitBrandViewResult((h.span([h.Role("status"), h.Class(`link-state${
|
|
13
|
+
return __foldkitBrandViewResult((h.span([h.Role("status"), h.Class(`link-state${state === "Online" ? "" : ` ${stateWord(state)}`}`)], [label, ...(isWorking ? [h.span([h.Class("cursor"), h.AriaHidden(true)])] : [])])), "@gjermundgaraba-designs/pixel-paper/src/linkState/linkState.js#view");
|
|
20
14
|
};
|
package/dist/src/menu/slip.js
CHANGED
|
@@ -23,8 +23,8 @@ const isNote = Item.$is("Note");
|
|
|
23
23
|
const entriesOf = (items) => __foldkitBrandViewResult((Array.flatMap(items, (item) => (__foldkitBrandViewResult((isGroup(item) ? item.items : [item]), "@gjermundgaraba-designs/pixel-paper/src/menu/slip.js#anonymous")))), "@gjermundgaraba-designs/pixel-paper/src/menu/slip.js#entriesOf");
|
|
24
24
|
const choosableIds = (items) => __foldkitBrandViewResult((Array.flatMap(entriesOf(items), (entry) => (__foldkitBrandViewResult((isNote(entry) ? [] : [entry.id]), "@gjermundgaraba-designs/pixel-paper/src/menu/slip.js#anonymous~2")))), "@gjermundgaraba-designs/pixel-paper/src/menu/slip.js#choosableIds");
|
|
25
25
|
const edgeAttributes = (context, id, h) => __foldkitBrandViewResult(([
|
|
26
|
-
...(Option.contains(context.firstId, id) ? [h.
|
|
27
|
-
...(Option.contains(context.lastId, id) ? [h.
|
|
26
|
+
...(Option.contains(context.firstId, id) ? [h.Attribute(FIRST_ATTRIBUTE, "")] : []),
|
|
27
|
+
...(Option.contains(context.lastId, id) ? [h.Attribute(LAST_ATTRIBUTE, "")] : []),
|
|
28
28
|
]), "@gjermundgaraba-designs/pixel-paper/src/menu/slip.js#edgeAttributes");
|
|
29
29
|
const wordsView = (entry, h) => __foldkitBrandViewResult(([
|
|
30
30
|
...(entry.glyph === undefined ? [] : [Glyph.view({ name: entry.glyph }, h)]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter.d.ts","sourceRoot":"","sources":["../../../src/meter/meter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAatD,0DAA0D;AAC1D,MAAM,M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Q,CAAC;IACpC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CACpC,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,UAAU,cAAc,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAMjF,CAAC"}
|
package/dist/src/meter/meter.js
CHANGED
|
@@ -34,36 +34,41 @@ const numbersText = (value, max, unit) => {
|
|
|
34
34
|
const numbers = `${value.toLocaleString(LOCALE)} / ${max.toLocaleString(LOCALE)}`;
|
|
35
35
|
return __foldkitBrandViewResult((unit === undefined ? numbers : `${numbers} ${unit}`), "@gjermundgaraba-designs/pixel-paper/src/meter/meter.js#numbersText");
|
|
36
36
|
};
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (isFull) {
|
|
41
|
-
return __foldkitBrandViewResult((Chip.view({ label: config.full ?? percentText, tone: "Blocked" }, h)), "@gjermundgaraba-designs/pixel-paper/src/meter/meter.js#percentView");
|
|
37
|
+
const levelOf = (value, max) => {
|
|
38
|
+
if (value >= max) {
|
|
39
|
+
return __foldkitBrandViewResult(("Full"), "@gjermundgaraba-designs/pixel-paper/src/meter/meter.js#levelOf");
|
|
42
40
|
}
|
|
43
|
-
else if (
|
|
44
|
-
return __foldkitBrandViewResult((
|
|
41
|
+
else if (value >= max * HIGH_SHARE) {
|
|
42
|
+
return __foldkitBrandViewResult(("High"), "@gjermundgaraba-designs/pixel-paper/src/meter/meter.js#levelOf");
|
|
45
43
|
}
|
|
46
44
|
else {
|
|
47
|
-
return __foldkitBrandViewResult((
|
|
45
|
+
return __foldkitBrandViewResult(("Calm"), "@gjermundgaraba-designs/pixel-paper/src/meter/meter.js#levelOf");
|
|
48
46
|
}
|
|
49
47
|
};
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const percentView = (config, percent, level, h) => {
|
|
49
|
+
const percentText = `${percent}%`;
|
|
50
|
+
if (level === "Full") {
|
|
51
|
+
return __foldkitBrandViewResult((Chip.view({ label: config.full ?? percentText, tone: "Blocked" }, h)), "@gjermundgaraba-designs/pixel-paper/src/meter/meter.js#percentView");
|
|
53
52
|
}
|
|
54
|
-
else if (
|
|
55
|
-
return __foldkitBrandViewResult((
|
|
53
|
+
else if (level === "High") {
|
|
54
|
+
return __foldkitBrandViewResult((Mark.readingView({ label: percentText }, h)), "@gjermundgaraba-designs/pixel-paper/src/meter/meter.js#percentView");
|
|
56
55
|
}
|
|
57
56
|
else {
|
|
58
|
-
return __foldkitBrandViewResult(("
|
|
57
|
+
return __foldkitBrandViewResult((h.span([h.Class("pct")], [percentText])), "@gjermundgaraba-designs/pixel-paper/src/meter/meter.js#percentView");
|
|
59
58
|
}
|
|
60
59
|
};
|
|
60
|
+
const TONE_CLASS = {
|
|
61
|
+
Full: " toned full",
|
|
62
|
+
High: " toned high",
|
|
63
|
+
Calm: " toned",
|
|
64
|
+
};
|
|
61
65
|
const meterView = (config, h) => {
|
|
62
66
|
const { id, label, value, max, detail = [], foot = [], isStale = false, hasNumbers = true, isToned = false, } = config;
|
|
63
67
|
const share = max > 0 ? Math.min(1, Math.max(0, value / max)) : 0;
|
|
64
|
-
const
|
|
68
|
+
const level = levelOf(value, max);
|
|
69
|
+
const isFull = level === "Full";
|
|
65
70
|
const numbers = config.valueText ?? numbersText(value, max, config.unit);
|
|
66
|
-
const rowClass = `meter-row${isStale ? " stale" : ""}${isToned ?
|
|
71
|
+
const rowClass = `meter-row${isStale ? " stale" : ""}${isToned ? TONE_CLASS[level] : ""}`;
|
|
67
72
|
return __foldkitBrandViewResult((UiMeter.view({
|
|
68
73
|
id,
|
|
69
74
|
value,
|
|
@@ -77,7 +82,7 @@ const meterView = (config, h) => {
|
|
|
77
82
|
]),
|
|
78
83
|
h.div([h.Class("meter-line")], [
|
|
79
84
|
h.span([...groups.meter, h.Class("cells")], cellRowView(METER_CELLS, scaled(share, METER_CELLS, isFull), h)),
|
|
80
|
-
percentView(config, scaled(share, PERCENT, isFull),
|
|
85
|
+
percentView(config, scaled(share, PERCENT, isFull), level, h),
|
|
81
86
|
...(hasNumbers ? [h.span([h.Class("meter-num tnum")], [numbers])] : []),
|
|
82
87
|
]),
|
|
83
88
|
...slotView("div", "meter-foot", foot, h),
|
|
@@ -6,6 +6,8 @@ import type { GlyphName } from "../glyph/glyphs.ts";
|
|
|
6
6
|
* change, in ink. `Quiet`: tinted, nothing wrong. */
|
|
7
7
|
export declare const Tone: Schema.Literals<readonly ["Warn", "Error", "Ok", "Quiet"]>;
|
|
8
8
|
export type Tone = typeof Tone.Type;
|
|
9
|
+
/** The class a tone adds to a notice's, a toast's or a glyph box's own. */
|
|
10
|
+
export declare const TONE_CLASS: Readonly<Record<Tone, string>>;
|
|
9
11
|
/** Configuration for the glyph box a Notice and an Outcome open with. */
|
|
10
12
|
export type ToneGlyphConfig = Readonly<{
|
|
11
13
|
tone: Tone;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notice.d.ts","sourceRoot":"","sources":["../../../src/notice/notice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD;sDACsD;AACtD,eAAO,MAAM,IAAI,4DAAoD,CAAC;AACtE,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"notice.d.ts","sourceRoot":"","sources":["../../../src/notice/notice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,KAAK,EAAE,U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
7
7
|
export const Tone = Schema.Literals(["Warn", "Error", "Ok", "Quiet"]);
|
|
8
8
|
const toneGlyph = (tone) => __foldkitBrandViewResult((Match.value(tone).pipe(Match.withReturnType(), Match.whenOr("Warn", "Error", () => __foldkitBrandViewResult(("bang"), "@gjermundgaraba-designs/pixel-paper/src/notice/notice.js#anonymous")), Match.when("Ok", () => __foldkitBrandViewResult(("check"), "@gjermundgaraba-designs/pixel-paper/src/notice/notice.js#anonymous~2")), Match.when("Quiet", () => __foldkitBrandViewResult(("info"), "@gjermundgaraba-designs/pixel-paper/src/notice/notice.js#anonymous~3")), Match.exhaustive)), "@gjermundgaraba-designs/pixel-paper/src/notice/notice.js#toneGlyph");
|
|
9
|
-
|
|
9
|
+
/** The class a tone adds to a notice's, a toast's or a glyph box's own. */
|
|
10
|
+
export const TONE_CLASS = {
|
|
10
11
|
Warn: "",
|
|
11
12
|
Error: " error",
|
|
12
13
|
Ok: " ok",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passwordField.d.ts","sourceRoot":"","sources":["../../../src/passwordField/passwordField.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAStD,wEAAwE;AACxE,eAAO,MAAM,QAAQ,2CAAmC,CAAC;AACzD,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAiB5C,gEAAgE;AAChE,MAAM,MAAM,UAAU,CAAC,OAAO,IAAI,QAAQ,CAAC;IACzC,8CAA8C;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACpC;gDAC4C;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,aAAa,E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