@gjermundgaraba-designs/simple-rat 0.0.0-stage → 0.8.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 +397 -0
- package/LICENSE +21 -0
- package/README.md +64 -2
- package/dist/highlight/highlight.d.ts +5 -0
- package/dist/highlight/highlight.d.ts.map +1 -0
- package/dist/highlight/highlight.js +71 -0
- package/dist/highlight/vite.d.ts +20 -0
- package/dist/highlight/vite.d.ts.map +1 -0
- package/dist/highlight/vite.js +37 -0
- package/dist/src/code/code.d.ts +20 -0
- package/dist/src/code/code.d.ts.map +1 -0
- package/dist/src/code/code.js +12 -0
- package/dist/src/code/index.d.ts +3 -0
- package/dist/src/code/index.d.ts.map +1 -0
- package/dist/src/code/index.js +1 -0
- package/dist/src/code-block/code-block.d.ts +31 -0
- package/dist/src/code-block/code-block.d.ts.map +1 -0
- package/dist/src/code-block/code-block.js +41 -0
- package/dist/src/code-block/index.d.ts +3 -0
- package/dist/src/code-block/index.d.ts.map +1 -0
- package/dist/src/code-block/index.js +1 -0
- package/dist/src/copy/copy.d.ts +83 -0
- package/dist/src/copy/copy.d.ts.map +1 -0
- package/dist/src/copy/copy.js +70 -0
- package/dist/src/copy-tab/copy-tab.d.ts +48 -0
- package/dist/src/copy-tab/copy-tab.d.ts.map +1 -0
- package/dist/src/copy-tab/copy-tab.js +31 -0
- package/dist/src/copy-tab/index.d.ts +3 -0
- package/dist/src/copy-tab/index.d.ts.map +1 -0
- package/dist/src/copy-tab/index.js +1 -0
- package/dist/src/diagram/diagram.d.ts +18 -0
- package/dist/src/diagram/diagram.d.ts.map +1 -0
- package/dist/src/diagram/diagram.js +18 -0
- package/dist/src/diagram/index.d.ts +3 -0
- package/dist/src/diagram/index.d.ts.map +1 -0
- package/dist/src/diagram/index.js +1 -0
- package/dist/src/footer/footer.d.ts +9 -0
- package/dist/src/footer/footer.d.ts.map +1 -0
- package/dist/src/footer/footer.js +3 -0
- package/dist/src/footer/index.d.ts +3 -0
- package/dist/src/footer/index.d.ts.map +1 -0
- package/dist/src/footer/index.js +1 -0
- package/dist/src/footnotes/footnotes.d.ts +12 -0
- package/dist/src/footnotes/footnotes.d.ts.map +1 -0
- package/dist/src/footnotes/footnotes.js +21 -0
- package/dist/src/footnotes/index.d.ts +3 -0
- package/dist/src/footnotes/index.d.ts.map +1 -0
- package/dist/src/footnotes/index.js +1 -0
- package/dist/src/header/header.d.ts +11 -0
- package/dist/src/header/header.d.ts.map +1 -0
- package/dist/src/header/header.js +8 -0
- package/dist/src/header/index.d.ts +3 -0
- package/dist/src/header/index.d.ts.map +1 -0
- package/dist/src/header/index.js +1 -0
- package/dist/src/heading/heading.d.ts +12 -0
- package/dist/src/heading/heading.d.ts.map +1 -0
- package/dist/src/heading/heading.js +12 -0
- package/dist/src/heading/index.d.ts +3 -0
- package/dist/src/heading/index.d.ts.map +1 -0
- package/dist/src/heading/index.js +1 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +18 -0
- package/dist/src/nav-link/index.d.ts +3 -0
- package/dist/src/nav-link/index.d.ts.map +1 -0
- package/dist/src/nav-link/index.js +1 -0
- package/dist/src/nav-link/nav-link.d.ts +13 -0
- package/dist/src/nav-link/nav-link.d.ts.map +1 -0
- package/dist/src/nav-link/nav-link.js +7 -0
- package/dist/src/note/index.d.ts +3 -0
- package/dist/src/note/index.d.ts.map +1 -0
- package/dist/src/note/index.js +1 -0
- package/dist/src/note/note.d.ts +12 -0
- package/dist/src/note/note.d.ts.map +1 -0
- package/dist/src/note/note.js +7 -0
- package/dist/src/pager/index.d.ts +3 -0
- package/dist/src/pager/index.d.ts.map +1 -0
- package/dist/src/pager/index.js +1 -0
- package/dist/src/pager/pager.d.ts +17 -0
- package/dist/src/pager/pager.d.ts.map +1 -0
- package/dist/src/pager/pager.js +15 -0
- package/dist/src/post-list/index.d.ts +3 -0
- package/dist/src/post-list/index.d.ts.map +1 -0
- package/dist/src/post-list/index.js +1 -0
- package/dist/src/post-list/post-list.d.ts +14 -0
- package/dist/src/post-list/post-list.d.ts.map +1 -0
- package/dist/src/post-list/post-list.js +6 -0
- package/dist/src/post-meta/index.d.ts +3 -0
- package/dist/src/post-meta/index.d.ts.map +1 -0
- package/dist/src/post-meta/index.js +1 -0
- package/dist/src/post-meta/post-meta.d.ts +11 -0
- package/dist/src/post-meta/post-meta.d.ts.map +1 -0
- package/dist/src/post-meta/post-meta.js +10 -0
- package/dist/src/scheme/index.d.ts +4 -0
- package/dist/src/scheme/index.d.ts.map +1 -0
- package/dist/src/scheme/index.js +3 -0
- package/dist/src/scheme/scheme-switch.d.ts +19 -0
- package/dist/src/scheme/scheme-switch.d.ts.map +1 -0
- package/dist/src/scheme/scheme-switch.js +27 -0
- package/dist/src/scheme/scheme.d.ts +8 -0
- package/dist/src/scheme/scheme.d.ts.map +1 -0
- package/dist/src/scheme/scheme.js +7 -0
- package/dist/src/scheme/script.d.ts +9 -0
- package/dist/src/scheme/script.d.ts.map +1 -0
- package/dist/src/scheme/script.js +8 -0
- package/dist/src/scheme/switch.d.ts +64 -0
- package/dist/src/scheme/switch.d.ts.map +1 -0
- package/dist/src/scheme/switch.js +67 -0
- package/dist/src/scrolls/index.d.ts +2 -0
- package/dist/src/scrolls/index.d.ts.map +1 -0
- package/dist/src/scrolls/index.js +1 -0
- package/dist/src/scrolls/scrolls.d.ts +19 -0
- package/dist/src/scrolls/scrolls.d.ts.map +1 -0
- package/dist/src/scrolls/scrolls.js +47 -0
- package/dist/src/skip-link/index.d.ts +2 -0
- package/dist/src/skip-link/index.d.ts.map +1 -0
- package/dist/src/skip-link/index.js +1 -0
- package/dist/src/skip-link/skip-link.d.ts +7 -0
- package/dist/src/skip-link/skip-link.d.ts.map +1 -0
- package/dist/src/skip-link/skip-link.js +6 -0
- package/dist/src/swatch/index.d.ts +2 -0
- package/dist/src/swatch/index.d.ts.map +1 -0
- package/dist/src/swatch/index.js +1 -0
- package/dist/src/swatch/swatch.d.ts +4 -0
- package/dist/src/swatch/swatch.d.ts.map +1 -0
- package/dist/src/swatch/swatch.js +3 -0
- package/dist/src/table/index.d.ts +3 -0
- package/dist/src/table/index.d.ts.map +1 -0
- package/dist/src/table/index.js +1 -0
- package/dist/src/table/table.d.ts +15 -0
- package/dist/src/table/table.d.ts.map +1 -0
- package/dist/src/table/table.js +25 -0
- package/highlight/highlight.ts +98 -0
- package/highlight/vite.ts +52 -0
- package/package.json +74 -3
- package/src/code/code.ts +30 -0
- package/src/code/index.ts +3 -0
- package/src/code/lines.d.ts +34 -0
- package/src/code-block/code-block.ts +101 -0
- package/src/code-block/index.ts +3 -0
- package/src/copy/copy.ts +97 -0
- package/src/copy-tab/copy-tab.ts +77 -0
- package/src/copy-tab/index.ts +12 -0
- package/src/diagram/diagram.ts +47 -0
- package/src/diagram/index.ts +3 -0
- package/src/footer/footer.ts +13 -0
- package/src/footer/index.ts +3 -0
- package/src/footnotes/footnotes.ts +56 -0
- package/src/footnotes/index.ts +3 -0
- package/src/header/header.ts +27 -0
- package/src/header/index.ts +3 -0
- package/src/heading/heading.ts +29 -0
- package/src/heading/index.ts +3 -0
- package/src/index.ts +35 -0
- package/src/nav-link/index.ts +3 -0
- package/src/nav-link/nav-link.ts +28 -0
- package/src/note/index.ts +3 -0
- package/src/note/note.ts +23 -0
- package/src/pager/index.ts +3 -0
- package/src/pager/pager.ts +34 -0
- package/src/post-list/index.ts +3 -0
- package/src/post-list/post-list.ts +30 -0
- package/src/post-meta/index.ts +3 -0
- package/src/post-meta/post-meta.ts +26 -0
- package/src/scheme/index.ts +5 -0
- package/src/scheme/scheme-switch.ts +55 -0
- package/src/scheme/scheme.ts +24 -0
- package/src/scheme/script.ts +10 -0
- package/src/scheme/switch.ts +88 -0
- package/src/scrolls/index.ts +1 -0
- package/src/scrolls/scrolls.ts +62 -0
- package/src/simple-rat.css +554 -0
- package/src/skip-link/index.ts +1 -0
- package/src/skip-link/skip-link.ts +8 -0
- package/src/swatch/index.ts +1 -0
- package/src/swatch/swatch.ts +5 -0
- package/src/table/index.ts +3 -0
- package/src/table/table.ts +59 -0
- package/src/tokens.css +58 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { LANGUAGES } from "../src/code/code.js";
|
|
4
|
+
import { highlight } from "./highlight.js";
|
|
5
|
+
const LINES_IMPORT = /^(?<file>[^?]+)\?(?:.*&)?lines=(?<lang>[^&]*)/u;
|
|
6
|
+
const isLanguage = (lang) => __foldkitBrandViewResult((LANGUAGES.some((known) => __foldkitBrandViewResult((known === lang), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#anonymous"))), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#isLanguage");
|
|
7
|
+
/**
|
|
8
|
+
* Colours code while the site is built, so no page loads the highlighter. An import with the
|
|
9
|
+
* query `?lines=<lang>` (one of `LANGUAGES`) is the file's text and its coloured lines,
|
|
10
|
+
* which `CodeBlock` takes as `code` and `lines`:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import retry from "./code/retry.txt?lines=ts";
|
|
14
|
+
*
|
|
15
|
+
* CodeBlock.view({ lang: "ts", ...retry, toParentMessage }, h);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Add it to the build's plugins, beside `foldkit()`. The file is watched, so a change to it
|
|
19
|
+
* colours it again. A `.txt` holds code the toolchain should leave alone; a source file can
|
|
20
|
+
* be imported twice, to run and to show.
|
|
21
|
+
*/
|
|
22
|
+
export const codeLines = () => (__foldkitBrandViewResult(({
|
|
23
|
+
name: "simple-rat:code-lines",
|
|
24
|
+
enforce: "pre",
|
|
25
|
+
async load(id) {
|
|
26
|
+
const { file, lang } = LINES_IMPORT.exec(id)?.groups ?? {};
|
|
27
|
+
if (file === undefined || lang === undefined) {
|
|
28
|
+
return __foldkitBrandViewResult((null), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#load");
|
|
29
|
+
}
|
|
30
|
+
if (!isLanguage(lang)) {
|
|
31
|
+
return __foldkitBrandViewResult((this.error(`simple-rat: ?lines=${lang} is none of ${LANGUAGES.join(", ")}`)), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#load");
|
|
32
|
+
}
|
|
33
|
+
this.addWatchFile(file);
|
|
34
|
+
const code = await readFile(file, "utf-8");
|
|
35
|
+
return __foldkitBrandViewResult((`export default ${JSON.stringify({ code, lines: highlight(code, lang) })};`), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#load");
|
|
36
|
+
},
|
|
37
|
+
}), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#codeLines"));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference path="../../../src/code/lines.d.ts" preserve="true" />
|
|
2
|
+
/** The languages a block can be coloured in. */
|
|
3
|
+
export declare const LANGUAGES: readonly ["ts", "tsx", "sh", "json", "css", "html", "diff"];
|
|
4
|
+
export type Language = (typeof LANGUAGES)[number];
|
|
5
|
+
/** One coloured run of a line: its text, the `--t-*` colour the highlighter gave it, and whether it
|
|
6
|
+
is italic. */
|
|
7
|
+
export type Run = Readonly<{
|
|
8
|
+
content: string;
|
|
9
|
+
color: string | undefined;
|
|
10
|
+
isItalic: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
/** A block's runs, line by line. A run in the plain code ink, upright, has no colour. */
|
|
13
|
+
export type Lines = ReadonlyArray<readonly Run[]>;
|
|
14
|
+
/** A file's text and its coloured lines: what an import with `?lines=<lang>` gives (see
|
|
15
|
+
lines.d.ts). */
|
|
16
|
+
export type Highlighted = Readonly<{
|
|
17
|
+
code: string;
|
|
18
|
+
lines: Lines;
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../src/code/code.ts"],"names":[],"mappings":";AAGA,gDAAgD;AAChD,eAAO,MAAM,SAAS,YACpB,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,CACE,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD;iBACiB;AACjB,MAAM,MAAM,GAAG,GAAG,QAAQ,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAEH,yFAAyF;AACzF,MAAM,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;AAElD;mBACmB;AACnB,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// oxlint-disable-next-line typescript/triple-slash-reference
|
|
2
|
+
/// <reference path="./lines.d.ts" preserve="true" />
|
|
3
|
+
/** The languages a block can be coloured in. */
|
|
4
|
+
export const LANGUAGES = [
|
|
5
|
+
"ts",
|
|
6
|
+
"tsx",
|
|
7
|
+
"sh",
|
|
8
|
+
"json",
|
|
9
|
+
"css",
|
|
10
|
+
"html",
|
|
11
|
+
"diff",
|
|
12
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LANGUAGES } from "./code.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
import type { Language, Lines } from "../code/code.ts";
|
|
3
|
+
import type { ViewInputs as CopyInputs } from "../copy-tab/copy-tab.ts";
|
|
4
|
+
import * as Scrolls from "../scrolls/scrolls.ts";
|
|
5
|
+
/** Configuration for rendering a code block with `view`. */
|
|
6
|
+
export type ViewConfig<ParentMessage> = Readonly<{
|
|
7
|
+
code: string;
|
|
8
|
+
/** The code's language, named on the `code` element. A block without one, with a copy
|
|
9
|
+
tab, is a prose block that wraps at text size, like a prompt. */
|
|
10
|
+
lang?: Language;
|
|
11
|
+
/** The code's coloured lines, made at build: an import with `?lines=<lang>` gives them
|
|
12
|
+
with the `code` (the package's `./highlight/vite`), or `highlight` makes them (its
|
|
13
|
+
`./highlight`). Without them the block is plain. */
|
|
14
|
+
lines?: Lines;
|
|
15
|
+
/** A file name, shown in a tab on the block's top-left edge. */
|
|
16
|
+
file?: string;
|
|
17
|
+
/** A `copy` tab on the block's top-right edge: the page's `CopyTab`, rendered with
|
|
18
|
+
`copyInputs`. The tab wraps the block, so it is given the block's view to render as its
|
|
19
|
+
`toBlockView`. */
|
|
20
|
+
copy?: ((toBlockView: () => Html) => Html) | undefined;
|
|
21
|
+
/** The overflow Mount's report, lifted into the page's Messages, which may ignore it. */
|
|
22
|
+
toParentMessage: (message: Scrolls.Message) => ParentMessage;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const nameOf: (code: string, file?: string) => string;
|
|
25
|
+
/** What a block's `CopyTab` is given: the block's name and its code, without a trailing
|
|
26
|
+
newline. */
|
|
27
|
+
export declare const copyInputs: (code: string, file?: string) => Omit<CopyInputs, "toBlockView">;
|
|
28
|
+
/** A code block: coloured where it is given its lines, optionally with a file tab and a
|
|
29
|
+
copy tab. Only a block that overflows takes focus, through `Scrolls.WatchOverflow`. */
|
|
30
|
+
export declare const view: <ParentMessage>(config: ViewConfig<ParentMessage>, h: HtmlBuilder<ParentMessage>) => Html;
|
|
31
|
+
//# sourceMappingURL=code-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../../src/code-block/code-block.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD,4DAA4D;AAC5D,MAAM,MAAM,UAAU,CAAC,aAAa,IAAI,QAAQ,CAAC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb;wEACoE;IACpE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;2DAEuD;IACvD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;yBAEqB;IACrB,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACvD,yFAAyF;IACzF,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,aAAa,CAAC;CAC9D,CAAC,CAAC;AAEH,eAAO,MAAM,MAAM,SAAU,MAAM,SAAS,MAAM,KAAG,MAMpD,CAAC;AAEF;eACe;AACf,eAAO,MAAM,UAAU,SACf,MAAM,SACL,MAAM,KACZ,IAAI,CAAC,UAAU,EAAE,aAAa,CAG/B,CAAC;AAuBH;0FAC0F;AAC1F,eAAO,MAAM,IAAI,GAAI,aAAa,UACxB,UAAU,CAAC,aAAa,CAAC,KAC9B,WAAW,CAAC,aAAa,CAAC,KAC5B,IA4BF,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { Option } from "effect";
|
|
3
|
+
import * as Mount from "foldkit/mount";
|
|
4
|
+
import * as Scrolls from "../scrolls/scrolls.js";
|
|
5
|
+
export const nameOf = (code, file) => {
|
|
6
|
+
const firstLine = code.trim().split("\n")[0] ?? "";
|
|
7
|
+
return (__foldkitBrandViewResult((file ?? (firstLine.length > 40 ? `${firstLine.slice(0, 40)}…` : firstLine)), "@gjermundgaraba-designs/simple-rat/src/code-block/code-block.js#nameOf"));
|
|
8
|
+
};
|
|
9
|
+
/** What a block's `CopyTab` is given: the block's name and its code, without a trailing
|
|
10
|
+
newline. */
|
|
11
|
+
export const copyInputs = (code, file) => (__foldkitBrandViewResult(({
|
|
12
|
+
name: nameOf(code, file),
|
|
13
|
+
text: code.trimEnd(),
|
|
14
|
+
}), "@gjermundgaraba-designs/simple-rat/src/code-block/code-block.js#copyInputs"));
|
|
15
|
+
const linesView = (lines, h) => __foldkitBrandViewResult((lines.flatMap((line, index) => __foldkitBrandViewResult(([
|
|
16
|
+
...(index > 0 ? ["\n"] : []),
|
|
17
|
+
...line.map((run) => __foldkitBrandViewResult((run.color === undefined
|
|
18
|
+
? run.content
|
|
19
|
+
: h.span([
|
|
20
|
+
h.Style({
|
|
21
|
+
color: run.color,
|
|
22
|
+
...(run.isItalic ? { fontStyle: "italic" } : {}),
|
|
23
|
+
}),
|
|
24
|
+
], [run.content])), "@gjermundgaraba-designs/simple-rat/src/code-block/code-block.js#anonymous~2")),
|
|
25
|
+
]), "@gjermundgaraba-designs/simple-rat/src/code-block/code-block.js#anonymous"))), "@gjermundgaraba-designs/simple-rat/src/code-block/code-block.js#linesView");
|
|
26
|
+
/** A code block: coloured where it is given its lines, optionally with a file tab and a
|
|
27
|
+
copy tab. Only a block that overflows takes focus, through `Scrolls.WatchOverflow`. */
|
|
28
|
+
export const view = (config, h) => {
|
|
29
|
+
const { code, lang, lines, file, copy, toParentMessage } = config;
|
|
30
|
+
const name = nameOf(code, file);
|
|
31
|
+
const toBlockView = () => __foldkitBrandViewResult((h.pre([
|
|
32
|
+
...(copy === undefined ? [] : [h.DataAttribute("copy", "")]),
|
|
33
|
+
h.OnMount(Mount.mapMessage(Scrolls.WatchOverflow({ maybeName: Option.some(name) }), toParentMessage)),
|
|
34
|
+
], [
|
|
35
|
+
h.code(lang === undefined ? [] : [h.Class(`language-${lang}`)], lines === undefined ? [code] : linesView(lines, h)),
|
|
36
|
+
])), "@gjermundgaraba-designs/simple-rat/src/code-block/code-block.js#toBlockView");
|
|
37
|
+
const body = copy === undefined ? toBlockView() : copy(toBlockView);
|
|
38
|
+
return __foldkitBrandViewResult((file === undefined
|
|
39
|
+
? body
|
|
40
|
+
: h.figure([h.Class("file")], [h.figcaption([], [file]), body])), "@gjermundgaraba-designs/simple-rat/src/code-block/code-block.js#view");
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code-block/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEnD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { copyInputs, view } from "./code-block.js";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Clipboard } from "@effect/platform-browser";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import * as Command from "foldkit/command";
|
|
4
|
+
import type * as Update from "foldkit/update";
|
|
5
|
+
/** Where a copy is: nothing yet, writing to the clipboard, just copied, or just refused. */
|
|
6
|
+
export declare const CopyState: import("foldkit/schema").TaggedUnion<{
|
|
7
|
+
readonly Idle: {};
|
|
8
|
+
readonly Copying: {};
|
|
9
|
+
readonly Copied: {};
|
|
10
|
+
readonly Failed: {};
|
|
11
|
+
}>;
|
|
12
|
+
export type CopyState = typeof CopyState.Type;
|
|
13
|
+
/** Schema for a copy control: what it says it just did. */
|
|
14
|
+
export declare const Model: Schema.Struct<{
|
|
15
|
+
readonly id: Schema.String;
|
|
16
|
+
readonly state: import("foldkit/schema").TaggedUnion<{
|
|
17
|
+
readonly Idle: {};
|
|
18
|
+
readonly Copying: {};
|
|
19
|
+
readonly Copied: {};
|
|
20
|
+
readonly Failed: {};
|
|
21
|
+
}>;
|
|
22
|
+
}>;
|
|
23
|
+
export type Model = typeof Model.Type;
|
|
24
|
+
/** Union of all Messages a copy control can produce. */
|
|
25
|
+
export declare const Message: import("foldkit/message").MessageUnion<{
|
|
26
|
+
readonly ClickedCopy: {
|
|
27
|
+
text: Schema.String;
|
|
28
|
+
};
|
|
29
|
+
readonly SucceededCopyText: {};
|
|
30
|
+
readonly FailedCopyText: {};
|
|
31
|
+
readonly CompletedWaitBeforeSettling: {};
|
|
32
|
+
}>;
|
|
33
|
+
export type Message = typeof Message.Type;
|
|
34
|
+
/** Configuration for creating a copy control with `init`: its id, unique in the document. */
|
|
35
|
+
export type InitConfig = Readonly<{
|
|
36
|
+
id: string;
|
|
37
|
+
}>;
|
|
38
|
+
/** Creates a copy control that has copied nothing. */
|
|
39
|
+
export declare const init: (config: InitConfig) => Model;
|
|
40
|
+
/** The control's id, unique in the document. */
|
|
41
|
+
export declare const id: (model: Model) => string;
|
|
42
|
+
/** Writes the text to the clipboard through Effect's `Clipboard` port. Provide
|
|
43
|
+
`Clipboard.layer` from `@effect/platform-browser` in the application's `resources`. */
|
|
44
|
+
export declare const CopyText: Command.CommandDefinitionWithArgs<"CopyText", {
|
|
45
|
+
text: Schema.String;
|
|
46
|
+
}, Effect.Effect<{
|
|
47
|
+
readonly _tag: "SucceededCopyText";
|
|
48
|
+
} | {
|
|
49
|
+
readonly _tag: "FailedCopyText";
|
|
50
|
+
}, never, Clipboard.Clipboard>>;
|
|
51
|
+
/** Waits out the beat the answer shows for. */
|
|
52
|
+
export declare const WaitBeforeSettling: Command.CommandDefinitionNoArgs<"WaitBeforeSettling", Effect.Effect<{
|
|
53
|
+
readonly _tag: "CompletedWaitBeforeSettling";
|
|
54
|
+
}, never, never>>;
|
|
55
|
+
/** Processes a copy control Message and returns the next Model and Commands. Its copy needs
|
|
56
|
+
the `Clipboard` service. A press counts only while the control is Idle, so one beat ends
|
|
57
|
+
before the next copy starts. */
|
|
58
|
+
export declare const update: (model: Model, message: Message) => Readonly<{
|
|
59
|
+
model: {
|
|
60
|
+
readonly id: string;
|
|
61
|
+
readonly state: {
|
|
62
|
+
readonly _tag: "Copied";
|
|
63
|
+
} | {
|
|
64
|
+
readonly _tag: "Copying";
|
|
65
|
+
} | {
|
|
66
|
+
readonly _tag: "Failed";
|
|
67
|
+
} | {
|
|
68
|
+
readonly _tag: "Idle";
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
commands?: Update.Commands<{
|
|
72
|
+
readonly _tag: "ClickedCopy";
|
|
73
|
+
readonly text: string;
|
|
74
|
+
} | {
|
|
75
|
+
readonly _tag: "CompletedWaitBeforeSettling";
|
|
76
|
+
} | {
|
|
77
|
+
readonly _tag: "FailedCopyText";
|
|
78
|
+
} | {
|
|
79
|
+
readonly _tag: "SucceededCopyText";
|
|
80
|
+
}, Clipboard.Clipboard>;
|
|
81
|
+
outMessage?: never;
|
|
82
|
+
}>;
|
|
83
|
+
//# sourceMappingURL=copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../../src/copy/copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAY,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAI3C,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAE9C,4FAA4F;AAC5F,eAAO,MAAM,SAAS;;;;;EAKpB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAE9C,2DAA2D;AAC3D,eAAO,MAAM,KAAK;;;;;;;;EAGhB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC;AAEtC,wDAAwD;AACxD,eAAO,MAAM,OAAO;;QACH,IAAI;;;;;EAInB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,6FAA6F;AAC7F,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAElD,sDAAsD;AACtD,eAAO,MAAM,IAAI,WAAY,UAAU,KAAG,KAGxC,CAAC;AAEH,gDAAgD;AAChD,eAAO,MAAM,EAAE,UAAW,KAAK,KAAG,MAAkB,CAAC;AAIrD;0FAC0F;AAC1F,eAAO,MAAM,QAAQ;;;;;;+BAUnB,CAAC;AAEH,+CAA+C;AAC/C,eAAO,MAAM,kBAAkB;;iBAK7B,CAAC;AASH;;mCAEmC;AACnC,eAAO,MAAM,MAAM,UAAW,KAAK,WAAW,OAAO;;;;;;;;;;;;;;;;;;;;;;;;EAcjD,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { Clipboard } from "@effect/platform-browser";
|
|
3
|
+
import { Duration, Effect, Schema } from "effect";
|
|
4
|
+
import * as Command from "foldkit/command";
|
|
5
|
+
import { defineMessageUnion } from "foldkit/message";
|
|
6
|
+
import { defineTaggedUnion } from "foldkit/schema";
|
|
7
|
+
import { modifyFields } from "foldkit/struct";
|
|
8
|
+
/** Where a copy is: nothing yet, writing to the clipboard, just copied, or just refused. */
|
|
9
|
+
export const CopyState = defineTaggedUnion({
|
|
10
|
+
Idle: {},
|
|
11
|
+
Copying: {},
|
|
12
|
+
Copied: {},
|
|
13
|
+
Failed: {},
|
|
14
|
+
});
|
|
15
|
+
/** Schema for a copy control: what it says it just did. */
|
|
16
|
+
export const Model = Schema.Struct({
|
|
17
|
+
id: Schema.String,
|
|
18
|
+
state: CopyState,
|
|
19
|
+
});
|
|
20
|
+
/** Union of all Messages a copy control can produce. */
|
|
21
|
+
export const Message = defineMessageUnion({
|
|
22
|
+
ClickedCopy: { text: Schema.String },
|
|
23
|
+
SucceededCopyText: {},
|
|
24
|
+
FailedCopyText: {},
|
|
25
|
+
CompletedWaitBeforeSettling: {},
|
|
26
|
+
});
|
|
27
|
+
/** Creates a copy control that has copied nothing. */
|
|
28
|
+
export const init = (config) => (__foldkitBrandViewResult(({
|
|
29
|
+
id: config.id,
|
|
30
|
+
state: CopyState.Idle(),
|
|
31
|
+
}), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#init"));
|
|
32
|
+
/** The control's id, unique in the document. */
|
|
33
|
+
export const id = (model) => __foldkitBrandViewResult((model.id), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#id");
|
|
34
|
+
const WORD_BEAT = Duration.millis(1600);
|
|
35
|
+
/** Writes the text to the clipboard through Effect's `Clipboard` port. Provide
|
|
36
|
+
`Clipboard.layer` from `@effect/platform-browser` in the application's `resources`. */
|
|
37
|
+
export const CopyText = Command.define("CopyText", {
|
|
38
|
+
args: { text: Schema.String },
|
|
39
|
+
messages: [Message.SucceededCopyText, Message.FailedCopyText],
|
|
40
|
+
execute: ({ text }) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
41
|
+
const clipboard = yield* Clipboard.Clipboard;
|
|
42
|
+
yield* clipboard.writeString(text);
|
|
43
|
+
return __foldkitBrandViewResult((Message.SucceededCopyText()), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#anonymous");
|
|
44
|
+
}).pipe(Effect.orElseSucceed(() => __foldkitBrandViewResult((Message.FailedCopyText()), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#anonymous~2")))), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#execute"),
|
|
45
|
+
});
|
|
46
|
+
/** Waits out the beat the answer shows for. */
|
|
47
|
+
export const WaitBeforeSettling = Command.define("WaitBeforeSettling", {
|
|
48
|
+
messages: [Message.CompletedWaitBeforeSettling],
|
|
49
|
+
execute: Effect.sleep(WORD_BEAT).pipe(Effect.as(Message.CompletedWaitBeforeSettling())),
|
|
50
|
+
});
|
|
51
|
+
const holdAnswer = (model, state) => (__foldkitBrandViewResult(({
|
|
52
|
+
model: modifyFields(model, { state: () => __foldkitBrandViewResult((state), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#state") }),
|
|
53
|
+
commands: [WaitBeforeSettling()],
|
|
54
|
+
}), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#holdAnswer"));
|
|
55
|
+
/** Processes a copy control Message and returns the next Model and Commands. Its copy needs
|
|
56
|
+
the `Clipboard` service. A press counts only while the control is Idle, so one beat ends
|
|
57
|
+
before the next copy starts. */
|
|
58
|
+
export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
59
|
+
ClickedCopy: ({ text }) => __foldkitBrandViewResult((CopyState.guards.Idle(model.state)
|
|
60
|
+
? {
|
|
61
|
+
model: modifyFields(model, { state: () => __foldkitBrandViewResult((CopyState.Copying()), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#state~2") }),
|
|
62
|
+
commands: [CopyText({ text })],
|
|
63
|
+
}
|
|
64
|
+
: { model }), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#ClickedCopy"),
|
|
65
|
+
SucceededCopyText: () => __foldkitBrandViewResult((holdAnswer(model, CopyState.Copied())), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#SucceededCopyText"),
|
|
66
|
+
FailedCopyText: () => __foldkitBrandViewResult((holdAnswer(model, CopyState.Failed())), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#FailedCopyText"),
|
|
67
|
+
CompletedWaitBeforeSettling: () => (__foldkitBrandViewResult(({
|
|
68
|
+
model: modifyFields(model, { state: () => __foldkitBrandViewResult((CopyState.Idle()), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#state~3") }),
|
|
69
|
+
}), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#CompletedWaitBeforeSettling")),
|
|
70
|
+
})), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#update");
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Html } from "foldkit/html";
|
|
2
|
+
export { CopyState, CopyText, Message, Model, WaitBeforeSettling, id, init, update, } from "../copy/copy.ts";
|
|
3
|
+
export type { InitConfig } from "../copy/copy.ts";
|
|
4
|
+
/** Per-render inputs passed to `view` through `h.submodel`'s `viewInputs`. */
|
|
5
|
+
export type ViewInputs = Readonly<{
|
|
6
|
+
/** What is copied, for the tab's accessible name: the block's file or first line. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** What goes on the clipboard. */
|
|
9
|
+
text: string;
|
|
10
|
+
/** The block the tab sits on, built where it is called (in the page's own Message
|
|
11
|
+
boundary, so its Mount reports to the page). */
|
|
12
|
+
toBlockView: () => Html;
|
|
13
|
+
}>;
|
|
14
|
+
/** `div.copyable`: the block, a `copy` tab on its top-right edge, built on `@foldkit/ui`'s
|
|
15
|
+
Button, that answers `copied` (or `select and copy` when the browser refuses) for a beat
|
|
16
|
+
and says so to screen readers through a visually hidden status. The tab takes a press only
|
|
17
|
+
while it reads `copy`, and is held (`aria-disabled`) while it answers. Its `CopyText`
|
|
18
|
+
Command needs `Clipboard.layer` in the application's resources. */
|
|
19
|
+
export declare const view: import("foldkit/submodel").View<{
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly state: {
|
|
22
|
+
readonly _tag: "Copied";
|
|
23
|
+
} | {
|
|
24
|
+
readonly _tag: "Copying";
|
|
25
|
+
} | {
|
|
26
|
+
readonly _tag: "Failed";
|
|
27
|
+
} | {
|
|
28
|
+
readonly _tag: "Idle";
|
|
29
|
+
};
|
|
30
|
+
}, {
|
|
31
|
+
readonly _tag: "ClickedCopy";
|
|
32
|
+
readonly text: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly _tag: "CompletedWaitBeforeSettling";
|
|
35
|
+
} | {
|
|
36
|
+
readonly _tag: "FailedCopyText";
|
|
37
|
+
} | {
|
|
38
|
+
readonly _tag: "SucceededCopyText";
|
|
39
|
+
}, Readonly<{
|
|
40
|
+
/** What is copied, for the tab's accessible name: the block's file or first line. */
|
|
41
|
+
name: string;
|
|
42
|
+
/** What goes on the clipboard. */
|
|
43
|
+
text: string;
|
|
44
|
+
/** The block the tab sits on, built where it is called (in the page's own Message
|
|
45
|
+
boundary, so its Mount reports to the page). */
|
|
46
|
+
toBlockView: () => Html;
|
|
47
|
+
}>>;
|
|
48
|
+
//# sourceMappingURL=copy-tab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-tab.d.ts","sourceRoot":"","sources":["../../../src/copy-tab/copy-tab.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,OAAO,EACP,KAAK,EACL,kBAAkB,EAClB,EAAE,EACF,IAAI,EACJ,MAAM,GACP,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb;uDACmD;IACnD,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC,CAAC;AAkBH;;;;sEAIsE;AACtE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;IA9Bf,qFAAqF;UAC/E,MAAM;IACZ,kCAAkC;UAC5B,MAAM;IACZ;uDACmD;iBACtC,MAAM,IAAI;GAgDxB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { Button as UiButton } from "@foldkit/ui";
|
|
3
|
+
import { defineView } from "foldkit/submodel";
|
|
4
|
+
import { CopyState, Message } from "../copy/copy.js";
|
|
5
|
+
export { CopyState, CopyText, Message, Model, WaitBeforeSettling, id, init, update, } from "../copy/copy.js";
|
|
6
|
+
const word = (state) => __foldkitBrandViewResult((CopyState.match(state, {
|
|
7
|
+
Idle: () => __foldkitBrandViewResult(("copy"), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#Idle"),
|
|
8
|
+
Copying: () => __foldkitBrandViewResult(("copy"), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#Copying"),
|
|
9
|
+
Copied: () => __foldkitBrandViewResult(("copied"), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#Copied"),
|
|
10
|
+
Failed: () => __foldkitBrandViewResult(("select and copy"), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#Failed"),
|
|
11
|
+
})), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#word");
|
|
12
|
+
const said = (state) => __foldkitBrandViewResult((CopyState.match(state, {
|
|
13
|
+
Idle: () => __foldkitBrandViewResult((""), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#Idle~2"),
|
|
14
|
+
Copying: () => __foldkitBrandViewResult((""), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#Copying~2"),
|
|
15
|
+
Copied: () => __foldkitBrandViewResult(("Copied"), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#Copied~2"),
|
|
16
|
+
Failed: () => __foldkitBrandViewResult(("Copy failed. Select the text and copy it by hand."), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#Failed~2"),
|
|
17
|
+
})), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#said");
|
|
18
|
+
/** `div.copyable`: the block, a `copy` tab on its top-right edge, built on `@foldkit/ui`'s
|
|
19
|
+
Button, that answers `copied` (or `select and copy` when the browser refuses) for a beat
|
|
20
|
+
and says so to screen readers through a visually hidden status. The tab takes a press only
|
|
21
|
+
while it reads `copy`, and is held (`aria-disabled`) while it answers. Its `CopyText`
|
|
22
|
+
Command needs `Clipboard.layer` in the application's resources. */
|
|
23
|
+
export const view = defineView((model, { name, text, toBlockView }, h) => __foldkitBrandViewResult((h.div([h.Class("copyable")], [
|
|
24
|
+
toBlockView(),
|
|
25
|
+
UiButton.view({
|
|
26
|
+
isDisabled: !CopyState.guards.Idle(model.state),
|
|
27
|
+
onClick: Message.ClickedCopy({ text }),
|
|
28
|
+
toView: ({ button }) => __foldkitBrandViewResult((h.button([...button, h.AriaLabel(`Copy ${name}`)], [word(model.state)])), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#toView"),
|
|
29
|
+
}, h),
|
|
30
|
+
h.span([h.Class("visually-hidden"), h.Role("status")], [said(model.state)]),
|
|
31
|
+
])), "@gjermundgaraba-designs/simple-rat/src/copy-tab/copy-tab.js#anonymous"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/copy-tab/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,KAAK,EACL,kBAAkB,EAClB,EAAE,EACF,IAAI,EACJ,MAAM,EACN,IAAI,GACL,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CopyText, Message, Model, WaitBeforeSettling, id, init, update, view, } from "./copy-tab.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
import * as Scrolls from "../scrolls/scrolls.ts";
|
|
3
|
+
/** Configuration for rendering a diagram with `view`. */
|
|
4
|
+
export type ViewConfig<ParentMessage> = Readonly<{
|
|
5
|
+
/** The drawing, in box-drawing characters. */
|
|
6
|
+
drawing: string;
|
|
7
|
+
/** What the diagram shows, for screen readers. */
|
|
8
|
+
label: string;
|
|
9
|
+
/** What the diagram shows, for everyone. Defaults to the label. */
|
|
10
|
+
caption?: ReadonlyArray<Html | string>;
|
|
11
|
+
/** The overflow Mount's report, lifted into the page's Messages, which may ignore it. */
|
|
12
|
+
toParentMessage: (message: Scrolls.Message) => ParentMessage;
|
|
13
|
+
}>;
|
|
14
|
+
/** A box-drawing diagram: an image to assistive technology, with a visible caption. The
|
|
15
|
+
role sits on the `pre`, so a diagram too wide for the screen can still take focus
|
|
16
|
+
(through `Scrolls.WatchOverflow`) and scroll. */
|
|
17
|
+
export declare const view: <ParentMessage>(config: ViewConfig<ParentMessage>, h: HtmlBuilder<ParentMessage>) => Html;
|
|
18
|
+
//# sourceMappingURL=diagram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagram.d.ts","sourceRoot":"","sources":["../../../src/diagram/diagram.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD,yDAAyD;AACzD,MAAM,MAAM,UAAU,CAAC,aAAa,IAAI,QAAQ,CAAC;IAC/C,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,OAAO,CAAC,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IACvC,yFAAyF;IACzF,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,aAAa,CAAC;CAC9D,CAAC,CAAC;AAEH;;oDAEoD;AACpD,eAAO,MAAM,IAAI,GAAI,aAAa,UACxB,UAAU,CAAC,aAAa,CAAC,KAC9B,WAAW,CAAC,aAAa,CAAC,KAC5B,IAsBF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
import { Option } from "effect";
|
|
3
|
+
import * as Mount from "foldkit/mount";
|
|
4
|
+
import * as Scrolls from "../scrolls/scrolls.js";
|
|
5
|
+
/** A box-drawing diagram: an image to assistive technology, with a visible caption. The
|
|
6
|
+
role sits on the `pre`, so a diagram too wide for the screen can still take focus
|
|
7
|
+
(through `Scrolls.WatchOverflow`) and scroll. */
|
|
8
|
+
export const view = (config, h) => {
|
|
9
|
+
const { drawing, label, caption = [label], toParentMessage } = config;
|
|
10
|
+
return __foldkitBrandViewResult((h.figure([], [
|
|
11
|
+
h.pre([
|
|
12
|
+
h.Role("img"),
|
|
13
|
+
h.AriaLabel(label),
|
|
14
|
+
h.OnMount(Mount.mapMessage(Scrolls.WatchOverflow({ maybeName: Option.none() }), toParentMessage)),
|
|
15
|
+
], [h.code([], [drawing])]),
|
|
16
|
+
h.figcaption([], caption),
|
|
17
|
+
])), "@gjermundgaraba-designs/simple-rat/src/diagram/diagram.js#view");
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/diagram/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { view } from "./diagram.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
/** Configuration for rendering the footer with `view`. */
|
|
3
|
+
export type ViewConfig = Readonly<{
|
|
4
|
+
/** The one line. */
|
|
5
|
+
body: ReadonlyArray<Html | string>;
|
|
6
|
+
}>;
|
|
7
|
+
/** A rule and one line. */
|
|
8
|
+
export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
|
|
9
|
+
//# sourceMappingURL=footer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../../src/footer/footer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,oBAAoB;IACpB,IAAI,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;CACpC,CAAC,CAAC;AAEH,2BAA2B;AAC3B,eAAO,MAAM,IAAI,GAAI,OAAO,UAClB,UAAU,KACf,WAAW,CAAC,OAAO,CAAC,KACtB,IAAsD,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
/** A rule and one line. */
|
|
3
|
+
export const view = (config, h) => __foldkitBrandViewResult((h.footer([], [h.hr([]), h.p([], config.body)])), "@gjermundgaraba-designs/simple-rat/src/footer/footer.js#view");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/footer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { view } from "./footer.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
/** A superscript number that jumps to the note numbered `noteNumber`; the note links back. */
|
|
3
|
+
export declare const refView: <Message>(noteNumber: number, h: HtmlBuilder<Message>) => Html;
|
|
4
|
+
/** Configuration for rendering the notes with `view`. */
|
|
5
|
+
export type ViewConfig = Readonly<{
|
|
6
|
+
/** The notes, numbered from 1. */
|
|
7
|
+
notes: ReadonlyArray<ReadonlyArray<Html | string>>;
|
|
8
|
+
}>;
|
|
9
|
+
/** The notes, numbered from 1, at the end of the page under a rule. Each ends in a `Back`
|
|
10
|
+
link named for the reference it returns to. */
|
|
11
|
+
export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
|
|
12
|
+
//# sourceMappingURL=footnotes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footnotes.d.ts","sourceRoot":"","sources":["../../../src/footnotes/footnotes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,8FAA8F;AAC9F,eAAO,MAAM,OAAO,GAAI,OAAO,cACjB,MAAM,KACf,WAAW,CAAC,OAAO,CAAC,KACtB,IASA,CAAC;AAEJ,yDAAyD;AACzD,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,kCAAkC;IAClC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;CACpD,CAAC,CAAC;AAEH;kDACkD;AAClD,eAAO,MAAM,IAAI,GAAI,OAAO,UAClB,UAAU,KACf,WAAW,CAAC,OAAO,CAAC,KACtB,IA2BA,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
/** A superscript number that jumps to the note numbered `noteNumber`; the note links back. */
|
|
3
|
+
export const refView = (noteNumber, h) => __foldkitBrandViewResult((h.sup([], [
|
|
4
|
+
h.a([h.Href(`#fn-${noteNumber}`), h.Id(`ref-${noteNumber}`)], [`${noteNumber}`]),
|
|
5
|
+
])), "@gjermundgaraba-designs/simple-rat/src/footnotes/footnotes.js#refView");
|
|
6
|
+
/** The notes, numbered from 1, at the end of the page under a rule. Each ends in a `Back`
|
|
7
|
+
link named for the reference it returns to. */
|
|
8
|
+
export const view = (config, h) => __foldkitBrandViewResult((h.section([h.Class("footnotes"), h.AriaLabel("Footnotes")], [
|
|
9
|
+
h.hr([]),
|
|
10
|
+
h.ol([], config.notes.map((note, index) => {
|
|
11
|
+
const noteNumber = index + 1;
|
|
12
|
+
return __foldkitBrandViewResult((h.li([h.Id(`fn-${noteNumber}`)], [
|
|
13
|
+
...note,
|
|
14
|
+
" ",
|
|
15
|
+
h.a([
|
|
16
|
+
h.Href(`#ref-${noteNumber}`),
|
|
17
|
+
h.AriaLabel(`Back to reference ${noteNumber}`),
|
|
18
|
+
], ["Back"]),
|
|
19
|
+
])), "@gjermundgaraba-designs/simple-rat/src/footnotes/footnotes.js#anonymous");
|
|
20
|
+
})),
|
|
21
|
+
])), "@gjermundgaraba-designs/simple-rat/src/footnotes/footnotes.js#view");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/footnotes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE/C,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { refView, view } from "./footnotes.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Html, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
/** Configuration for rendering the header with `view`. */
|
|
3
|
+
export type ViewConfig = Readonly<{
|
|
4
|
+
/** `NavLink`s, and optionally a `SchemeSwitch` last. */
|
|
5
|
+
items: readonly Html[];
|
|
6
|
+
}>;
|
|
7
|
+
/** The page's header: a nav named "Primary navigation", a line of lowercase links separated
|
|
8
|
+
by middots, then a rule. Each item after the first sits in a `span` with its middot, so a
|
|
9
|
+
wrapped line starts with the middot instead of ending on one. */
|
|
10
|
+
export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
|
|
11
|
+
//# sourceMappingURL=header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/header/header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,wDAAwD;IACxD,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;CACxB,CAAC,CAAC;AAEH;;oEAEoE;AACpE,eAAO,MAAM,IAAI,GAAI,OAAO,UAClB,UAAU,KACf,WAAW,CAAC,OAAO,CAAC,KACtB,IAYA,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
+
/** The page's header: a nav named "Primary navigation", a line of lowercase links separated
|
|
3
|
+
by middots, then a rule. Each item after the first sits in a `span` with its middot, so a
|
|
4
|
+
wrapped line starts with the middot instead of ending on one. */
|
|
5
|
+
export const view = (config, h) => __foldkitBrandViewResult((h.header([], [
|
|
6
|
+
h.nav([h.AriaLabel("Primary navigation")], config.items.flatMap((item, index) => __foldkitBrandViewResult((index === 0 ? [item] : [" ", h.span([], ["· ", item])]), "@gjermundgaraba-designs/simple-rat/src/header/header.js#anonymous"))),
|
|
7
|
+
h.hr([]),
|
|
8
|
+
])), "@gjermundgaraba-designs/simple-rat/src/header/header.js#view");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/header/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { view } from "./header.js";
|